Google App Engine - NDB - Setting Property Value for Multiple Entries

I use NDB and Python in the Google App Engine. What is the correct way to update a property for multiple objects with the same value? NDB Equivalent:

UPDATE notifications SET read = true WHERE user_id = 123.

Use case: I have these disconnect notifications. And a specific user wants to set all their notifications as read (potentially 100). I know that I could use get_async and put_async to retrieve each unread notification and set it as read, but I'm worried about the delay that is created by collecting potentially 100 serialization / deserialization.

Any advice is very helpful.

+4
source share
1 answer

You can call a function for each object using map()the Query method. For best performance do not forget _async.

But one of the most useful GAE services is Task Queues, especially in such cases. If you combine Query Cursors and a deferred library , you can easily process any number of objects.

+2
source

All Articles