Thursday 16 March 2017

Is there optimistic locking in Google Datastore node api?

I need to implement optimistic on my google datastore kind.

I am using my own key rather than a generated one and using the google datastore node.js api.

As insert, update, upsert all seem to de delegated to the save() method ( as per the docs) I can easily end up overwriting data if I am not careful.

So basically I have to try a 'read' before doing any insert or update and then after that I have to be careful to 'overwrite' the correct properties before calling save().

If I manage to read and then properly 'overwrite' the correct fields I still need to be sure that I am the latest writer to that entity so I would need some sort of optimistic locking with a version/timestamp field. I have read somewhere that this is in built in but its not so explicit in the official docs at https://googlecloudplatform.github.io/google-cloud-node/#/docs/datastore/0.7.1/datastore?method=insert

can someone shed some light on this ?



via 1977

No comments:

Post a Comment