简体   繁体   English

如何改变ndb重复属性?

[英]How to mutate a ndb repeated property?

The appengine docu says on repeated ndb properiertes, that: appengine文件说明了重复的ndb专业人士:

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#repeated

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! 谢谢!

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. Yes exactly like that. 是的,就是这样。 Appending like a normal list, deleting, etc etc. 附加正常列表,删除等等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM