db.collection(...)。set不是函数

我试图在有人登录我的网站时进行更新或创建统计信息。

我有这个代码

$ctlr->{$url[1]}();

它应该可以工作,但是当我尝试运行它时,它说控制台中的db.collection(...)。set不是一个函数

我该怎么办?

nhzjc 回答:db.collection(...)。set不是函数

db.collection(“ users”)返回CollectionReference的对象。 CollectionReference没有函数“设置”,因此会出错。 也许您正在寻找添加文档的功能“添加”。

替换

                db.collection("users").set({
                    points: 0,CurrentLevel: 0
                })

使用

                db.collection("users").add({
                    points: 0,CurrentLevel: 0
                })

我认为应该可以解决您的问题

本文链接:https://www.f2er.com/3128691.html

大家都在问