【发布时间】:2020-09-30 12:36:59
【问题描述】:
我已阅读以下所有问题,但在文档中找不到任何内容来描述如何同步集合并仅从集合中接收已更改的文档。我的同步集合中有 500 多个文档(使用 redux-saga-firebase syncCollection),但通常只有大约 100 个文档会更改。在任何给定时间,甚至更少会发生变化,但我目前正在获取所有 500+ 个文档,即使一个文档发生更改,也会导致 500+ 次读取。不理想,而且会大量花费我。
这是我使用 redux-saga-firebase 的代码,但一个普通的 firebase 代码答案也足够了。如何获得同步响应,仅发送集合中已更改的文档?
export function* getPlayersFromDb() {
yield fork(
rsf.firestore.syncCollection,
'players',
{ successActionCreator: response => ({
type: t.GET_PLAYERS_FROM_DB_SUCCESS,
payload: [...response],
}),
failureActionCreator: () => ({
type: t.GET_PLAYERS_FROM_DB_FAILURE,
payload: [],
}),
transform: response => messageTransformer(response),
}
);
}
Does Firestore sync only diff?
Realm syncing with large collection on Firestore - architectural questions / issues
【问题讨论】:
标签: javascript firebase google-cloud-firestore