Reputation: 1763
Is it safe to use the object.attributes property of a Parse.Object when reading and writing?
I know the way it says in the docs to use a Parse.Object is via
object.set("myprop",0)
and
object.get("myprop")
but can I just do
object.attributes.myprop = 0
and
var x = object.attributes.myprop;
will that work when calling object.save()?
Upvotes: 4
Views: 1243
Reputation: 436
Since Parse JavaScript SDK is based on Backbonejs, Parse.Object shares a lot with Backbone.Model
In this scenario, instead of just changing the value of the property, 'set' changes the model's state which may affect other operations, for example, the dirty checking, and so the model would overlook the changes and therefore fail to update.
Upvotes: 2
Reputation: 5960
I tested the code you gave and it does not work. You do have to use the get and set functions on an object. Why are you against using them?
Works:
object.set("myprop",0);
object.get("myprop");
Doesn't Work:
object.attributes.myprop = 0;
object.attributes.myprop;
Upvotes: 1