Updating a table record without losing its relations

Let me explain a little bit of background before attempting my question:

I have 2 tables;

OrderBatchJob
Orders

OrderBatchJob has a field called ‘orders’ which has a 1-to-N relationship with the Orders table.

When my batch job processor (a Java based app) retrieves a new OrderBatchJob record from Backendless, I addRelation(“orders”) to get all its associated orders.

The batch job processing occurs in several stages, and at at stage I modify the the contents of OrderBatchJob.status (a simple string field) and then run a .save operation on it.

This operation means all the Orders associated with it (i.e. OrderBatchJob.orders) are also sent back to Backendless from the client for every .save() invokation. I’d like to speed up the transaction by somehow only modifying OrderBatchJob.status and leaving OrderBatchJob.orders as they were at the point in time of the original retrieval. Is there a way to do this?

In SQL terms it’s like I just want to update one field in in the parent table.

Hi, Simon! This is the way Backendless Persistence service works - if you update the field in Parent object all the Child objects will be updated too.
But if you don’t want to send all the related Child objects when you update only one field in Parent object you can do it the following way:

At first you retrieve OrderBatchJob object containing orders objects and process it.
Then before updating the OrderBatchJob.status you do another request for retrieving ObjectBatchJob BUT specifying RelationDepth==0. Then update the status field in this retrieved ObjectBatchJob object and save it - in this case the Order objects will not be sent to the server and modified.
You better check if this method buys you anything since you have to perform another request with RelationDepth==0.

Understood, thanks for the great answer! I’ll give that a go :slight_smile: