什么被认为是针对 Google Cloud Datastore 中的实体组限制的写入

What is considered a write against the entity group limit in Google Cloud Datastore

根据数据存储文档,实体组的最大写入速率为每秒 1 个。

https://cloud.google.com/datastore/docs/concepts/limits

我想知道这种情况是作为单个查询还是多个查询计入该限制。

Stack Overflow 上也有类似的问题 - 但他们似乎没有确认您可以做什么。

const datastore = require('@google-cloud/datastore')();

const key1 = datastore.key(['Users', 1, 'Comments']);

const comment1 = {
    userId: 1,
    commentBody: '...',
    ts: new Date(),
};

const key2 = datastore.key(['Users', 2, 'Comments']);

const comment2 = {
    userId: 2,
    commentBody: '...',
    ts: new Date(),
};

datastore.save({
    key: key1,
    data: comment1
}, (err) => {
    //
});

datastore.save({
    key: key2,
    data: comment2
}, (err) => {
    //
});

在这里查看您的实体,您有 2 个实体组:

  1. Users/1
  2. Users/2

然后你保存2个评论实体,每个实体组一个。这算作每个实体组 1 次写入。