According to the Datastore documentation, there is a maximum write rate to an entity group of 1 per second.
https://cloud.google.com/datastore/docs/concepts/limits
I'd like to know if this scenario counts towards that limit as a single, or multiple queries.
There have been similar questions on Stack Overflow - but they don't seem to confirm what you can do.
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) => {
//
});
Looking at your entities here, you have 2 entity groups:
Then you save 2 comment entities, one under each entity group. This counts as 1 write per entity-group.