我正在尝试为Firestore实时监听程序找出一个解决方案。我知道您可以监听更改,并在onSnapshot中查看添加、删除、更改的内容。但是,有没有一种方法可以只监听加法呢?
我不喜欢任何时候只要数据发生变化,或者添加了新文档,查询就会检索每一条数据。感觉像是唯一的数据传输..尤其是当您在3G网络上使用该应用程序时
这是一个合理的担忧吗?或者查询返回的数据可以忽略不计?我只想将“新的”内容添加到集合中。
发布于 2018-06-27 02:17:53
你试过这个吗?
exports.createUser = functions.firestore
.document('users/{userId}')
.onCreate((snap, context) => {
// Get an object representing the document
// e.g. {'name': 'Marie', 'age': 66}
const newValue = snap.data();
// access a particular field as you would any JS property
const name = newValue.name;
// perform desired operations ...
});
https://stackoverflow.com/questions/49040855
复制