Backendless Support
 
Waiting for user's response

iOS - avoid saving certain properties

We're building a system that uses an event handler to add a custom property to an object.

We want to be able to read these properties in iOS without saving back to the server when a save function is called.

According to this previous post - http://support.backendless.com/topic/saving-only-some-properties-of-an-object - the data model must only contain properties that will be saved to the database.

Leave a Comment

Comments (3)

photo
1

Hi Cameron,

When you add a "dynamic" property in your event handler, it does not need to be a part of the data model. I assume you have an "after" event handler for an API event which returns a data object (or a collection of those).

The property you add would be accessible with the same mechanism as properties which come from the data model. That is, you'd declare a property in the client-side class and should be initialized when the object is returned from the server.

Regards,

Mark

photo
1

Mark,

You're absolutely right - we're using an after event handler to return the data object with the dynamic property.

On the iOS side, we declare the property in the client-side class so it is initialized when the object is returned from the server.

When we re-save this object, Backendless creates new columns/tables/relations on the server side to accommodate the additional "dynamic" property.

Since this property is dynamically generated, it should not be persisted in storage.

photo
1

Cameron,

Yes, what you described is exactly how it will work out of the box. To make it symmetric, I would recommend adding a "before" handler, where you can remove the dynamic property from the object thus a column will not be created.

Regards,

Mark

photo