Hello everyone,
I’m trying to update a model’s data from another table’s post route.
Here is the code I have:
router.post(
"/bookings",
permissionMiddlewareCreator.create(),
(request, response, next) => {
const recordCreator = new RecordCreator(bookings);
const tableRecordUpdater = new RecordUpdater(tables);
// Get the values of the input fields entered by the admin user.
request.body.data.attributes.accessLink = `lords://${uuid()}`;
recordCreator
.deserialize(request.body)
.then((recordToCreate) => recordCreator.create(recordToCreate))
.then((record) => {
console.log(record.dataValues.bookingId);
return recordCreator.serialize(record);
})
.then((recordSerialized) => response.send(recordSerialized))
.catch((next) => {
console.log(next);
});
}
);
It is at the line where I currently have console.log(record.dataValues.bookingId);
that I want to update the model tables
.
I have already added a RecordUpdater for that model. However, I am not sure how I can generate de data I need to feed that function. From this link https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#update-a-record, I do not know how I can build the request.body
object from the bookings’ post route.
If any of you has any suggestions, it would be great.
Thanks