简体   繁体   English

谷歌云数据存储API更新问题

[英]google cloud datastore API update issue

Following the guidance provided here ( https://cloud.google.com/datastore/docs/concepts/transactions ), I'm creating an entity with below schema 按照此处提供的指导( https://cloud.google.com/datastore/docs/concepts/transactions ),我将使用以下架构创建一个实体

data: [
            {
                name: 'created',
                value: new Date().toJSON()
            },
            {
                name: 'name',
                value: templateObj.name,
                excludeFromIndexes: true
            }
        ]

I see this goes thru as expected and notice that the column "name" is not indexed. 我看到这如预期的那样进行,请注意未对“名称”列进行索引。 在此处输入图片说明

Now, I use the transaction and update the entity. 现在,我使用事务并更新实体。 Below is the payload 以下是有效载荷

[
  {
    "property": "active",
    "value": false
  },
  {
    "property":"name",
    "value":"new updated template"
  }
]

Code is exactly the same as documented. 代码与记录的完全相同。

While updating the data, why does it update the schema? 在更新数据时,为什么要更新架构?

在此处输入图片说明

There is really no schema when it comes to Cloud Datastore. 关于Cloud Datastore,实际上没有任何架构。 It is schemaless. 它是无模式的。 Any time you save (Insert or Update) an entity (regardless of its Kind), you have to specify whether or not the properties in the entity should be indexed. 无论何时保存(插入或更新)实体(无论其种类如何),都必须指定是否应为实体中的属性建立索引。 If you do not explicitly set the excludeFromIndexes, the property will be indexed. 如果未显式设置excludeFromIndexes,则将对属性建立索引。 So, when you create an entity or update an existing entity, make sure to set the excludeFromIndexes to false if you want to keep the property unindexed. 因此,在创建实体或更新现有实体时,如果要保持属性未索引,请确保将excludeFromIndexes设置为false。

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

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