我正在使用 Node.js,不想每次更新都覆盖整个实体,大多数时候只需要更新特定的属性,例如计数器。
文档中没有关于如何执行此操作的明显引用。
Node.js 版本的 Google Cloud Datastore 是否支持像 Mongodb $set 这样的部分更新?
最佳答案
除了 put() 和 putmulti() 之外,没有用于更新实体的 DataStore API,因此这几乎是不可能的。
一点阅读 from here说出原因。
Internally, App Engine stores entities in protocol buffers, efficient mechanisms for serializing structured data; see the open source project page for more details. Instead of storing each entity property as an individual column in the corresponding Bigtable row, a single column is used which contains a binary-encoded protocol buffer containing the names and values for every property of a given entity.
简而言之,Datastore 中的实体行是底层存储方案中的单个二进制值,这就是没有用于部分更新的 API 的原因。
关于node.js - Google Cloud Datastore 是否支持像 Mongodb $set 这样的部分更新?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35884724/