Hi all,
i have this objects Rooms and Reservations whit a relationship(Reservations have a Room field inside)
When i want to save a new Reservation, the room field is a exist object, then i try with this call:
let reservation = ...// save reservation
let rooms = ...// save rooms
Backendless.Data.of( "Reservation" ).setRelation(
reservation,
"room",
rooms )
.then( function( count ) {
//count is a number of created relations
})
.catch( function( error ) {
});
sorry, maybe i explained myself wrong.
From my app i call the api of the service i created, then when i want to add a reservation, i call (for example):
as this is your service you are responsible to provide correct body, so I cannot tell what the body should be
what does this method should do? if create relation then
Backendless.Data.of( "Reservation" ).setRelation(
reservation,
"room",
rooms )
.then( function( count ) {
//count is a number of created relations
})
.catch( function( error ) {
});
where reservation is Reservation object with contains not empty “objectId” property,
rooms array wich cotains Rooms objects which contains not empty “objectIds”
you have to call setRelation or addRelation method every time you want to create relation.
I have tested whit this method in the ‘Api Service’ but i receive this error:
400 - Invalid value for the “parent” argument. The argument is required and must contain only string or object values.
i used your code and when i test the service the response is ok (200) and save the reservation object in db, but the field room is empty.
What did i wrong?