【发布时间】:2017-11-01 21:14:32
【问题描述】:
来自 Firebase 实时数据库,我想知道 Cloud Firestore 是否具有与 updateChildren() 功能等效的功能。它可以同时批量更新多个节点,如果失败则不更新。
【问题讨论】:
标签: firebase-realtime-database google-cloud-firestore batch-updates
来自 Firebase 实时数据库,我想知道 Cloud Firestore 是否具有与 updateChildren() 功能等效的功能。它可以同时批量更新多个节点,如果失败则不更新。
【问题讨论】:
标签: firebase-realtime-database google-cloud-firestore batch-updates
Firestore 支持可以将多个文档作为一个单元更新的事务,如果任何更新失败,则不支持:
https://cloud.google.com/firestore/docs/manage-data/transactions
这是来自所引用页面的 sn-p:
// Get a new write batch
var batch = db.batch();
// Set the value of 'NYC'
var nycRef = db.collection("cities").doc("NYC");
batch.set(nycRef, {name: "New York City"});
// Update the population of 'SF'
var sfRef = db.collection("cities").doc("SF");
batch.update(sfRef, {"population": 1000000});
// Delete the city 'LA'
var laRef = db.collection("cities").doc("LA");
batch.delete(laRef);
// Commit the batch
batch.commit().then(function () {
// ...
});
【讨论】:
keepSynced(true) 也许 Cloud Firestore 有类似的东西