如何对ndb重复属性进行突变?

时间:2021-10-26 23:14:54

The appengine docu says on repeated ndb properiertes, that:

附属引擎在重复的ndb properiertes上说:

When updating a repeated property, you can either assign it a new list or mutate the existing list in place.

当更新一个重复的属性时,您可以为它分配一个新的列表,或者修改现有的列表。

https://developers.google.com/appengine/docs/python/ndb/properties#repeated

https://developers.google.com/appengine/docs/python/ndb/properties重复

Two questions:

两个问题:

  1. do I save write operations when I just mutate the list, instead of putting a new list in place?

    当我只是修改列表的时候,我是否保存了写操作,而不是将一个新的列表放在适当的位置?

  2. how do I do exactly the mutation? just append the object and delete items within the list as I would do it with a list in python?

    我该怎么做这个突变呢?只是添加对象并删除列表中的项,就像我在python中使用列表那样?

Thanks!

谢谢!

1 个解决方案

#1


6  

Yes you have it correct in your mind.

是的,你的想法是对的。

  1. No you don't save because it's still a write operations with the applied costs.
  2. 不,你不保存,因为它仍然是一个写操作和应用的成本。
  3. Yes exactly like that. Appending like a normal list, deleting, etc etc.
  4. 是的一模一样。附加像一个普通的列表,删除等。

#1


6  

Yes you have it correct in your mind.

是的,你的想法是对的。

  1. No you don't save because it's still a write operations with the applied costs.
  2. 不,你不保存,因为它仍然是一个写操作和应用的成本。
  3. Yes exactly like that. Appending like a normal list, deleting, etc etc.
  4. 是的一模一样。附加像一个普通的列表,删除等。