无效的集合引用。集合引用必须具有奇数段。

huangapple go评论54阅读模式
英文:

Invalid collection reference Collection references must have an odd number of segments

问题

我目前在我的React Native应用中遇到了这个问题,使用Firebase时,尝试更新Firestore文档时出现了问题。
这是整个问题日志:

> 无效的集合引用。集合引用必须具有奇数段,但Posts/6ePmGkmxgQkq1PT0q3Yt有2个段。

!以下是我的代码:

无效的集合引用。集合引用必须具有奇数段。

“idPost”是文档的ID。

希望你们能帮助我解决这个问题,提前谢谢。

英文:

I am currently encountering this problem in my react native app using Firebase when im trying to update the document to firestore.
This is all problem log:

> Invalid collection reference. Collection references must have an odd number of segments, but Posts/6ePmGkmxgQkq1PT0q3Yt has 2.

!Here is my code:

无效的集合引用。集合引用必须具有奇数段。

the "idPost" is the id of the document.

I hope you guys can help me solve this problem, thank you in advanced

答案1

得分: 0

如果你想要更新一个文档,需要使用的 API 调用是 updateDoc 而不是 addDoc(后者是将文档添加到一个集合中)。

英文:

If you want to update a document, the API call to make is updateDoc and not addDoc (which adds a document to a collection).

huangapple
  • 本文由 发表于 2023年2月27日 03:09:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/75574386.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定