根据数据存储文档,实体组的最大写入速率为每秒 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
- 用户/2
然后您保存 2 个评论实体,每个实体组下一个。这算作每个实体组 1 次写入。
关于node.js - 什么被视为针对 Google Cloud Datastore 中的实体组限制的写入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43363902/