Firebase 函数 - 无法获取集合

时间:2021-02-02 14:00:35

标签: node.js firebase google-cloud-firestore google-cloud-functions

第一次使用预定的 Firebase 函数。我有问题,以下代码不返回集合。

你有什么解决办法吗?

import * as functions from "firebase-functions";
import * as admin from "firebase-admin";
admin.initializeApp();



export const setOverdue = functions.region("europe-west1").pubsub.schedule("* * * * *").onRun(async () => {
    const usercollection = await admin.firestore().collection("user").get();
    console.log(usercollection.docs.length); <-- This is always "0", even tho i have multiple user obkects
    
});

1 个答案:

答案 0 :(得分:0)

问题是我使用了错误的区域:

r.region("europe-west1")

改为

r.region("europe-west3") 

它奏效了