【问题标题】:Firebase Functions - Cannot get collectionFirebase 函数 - 无法收集
【发布时间】:2021-04-01 03:17:10
【问题描述】:

第一次使用预定的 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
    
});

【问题讨论】:

  • 你能显示你在user中的数据吗?
  • 用户包含 10 个文档,这些文档都包含一个集合

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


【解决方案1】:

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

r.region("europe-west1")

改为

r.region("europe-west3") 

成功了

【讨论】:

    猜你喜欢
    • 2022-10-07
    • 2019-02-21
    • 2019-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-21
    • 2019-11-11
    • 1970-01-01
    相关资源
    最近更新 更多