I’m trying to save an API response from an external source in a Backendless table. It works except with the nested arrays. The data are coming from an MLS system (Real Estate), each object (Property) has an array for Media (images). My idea is to save the x media files per property in a separate table and connect the property in one table via object relation with the media files from the other table (One to n).
Here is a screenshot how the JSON response looks like:
I tried a bunch of things but most of the time when I’m trying to get the data inside the Media array, I get the error 0 “Objects must be provided and must be an array of objects.”
When you use upsert it relies on the objectId property, when it persists in the payload and on the server, there is an object with the objectId it updates the object on the server, but when there is no object with provided objectId or the objectId wasn’t provided it always creates a new one.
so, bulkUsert won’t work for you because you load objects from the external service and these objects do not contain the objectId property.
I can recommend you to use deepSave feature, which saves a new object with its relations.
I’m getting a unique ID from the external database (Lets call it propertyID). Unfortunately, I cannot change from the Backendless objectID to the propertyID but what if I set the constrain for the propertyID to unique and indexed? Then it should look for the ID and only update the data if property exists or create a new one if propertyID doesn’t exist. What do you think?
But I’ll also check the option with the deepSave feature.