Firestore Local 持久性是否可用于 Windows/

Is Firestore Local persistence available for Windows/

我是运行以下代码:

const { initializeApp } = require('firebase-admin/app');
const { getFirestore  } = require('firebase-admin/firestore');
const {firestore} = require("firebase-admin");
const QuerySnapshot = firestore.QuerySnapshot;

initializeApp()
const db = getFirestore();

const initializeListener = (collectionName) => {
console.log('called function');
const query = db.collection(collectionName);

query.onSnapshot((querySnapshot) => {
    querySnapshot.docs().
    console.log('snapshot received');
    querySnapshot.docChanges().forEach((change) => {
        console.log('doc change found');
        if (change.type === "added") {
            console.log("New " + collectionName, change.doc.data());
        }
    });
}, (erry) => {
    console.log(`Encountered error: ${err}`);
});
}

initializeListener('my_collection');

如果 运行 在离线状态下,我在上线之前看不到 'snapshot received' 消息。如果此处应提供离线持久性,我该如何访问它?

您正在使用 Firebase Admin SDK(Google 云后端 SDK 的包装器),它在任何平台上都没有任何持久性。 Offline persistence 仅适用于 Firebase 提供的网络和客户端 SDK。正如您从链接文档中看到的那样:

Note: Offline persistence is supported only in Android, Apple, and web apps.