如何在 Firebase Firestore Web 版 V9 中更新子集合中的文档

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

How to update a document in a subcollection, Firebase Firestore Web V9

问题

我已经能够获取并添加数据到子集合 transactions/pullout_requests/requests/ 中,但我不知道如何更新其中的文档。我有需要更新的文档的文档 ID,但在 文档 中找不到 update 方法。

英文:

i have a subcollection transactions/pullout_requests/requests/

如何在 Firebase Firestore Web 版 V9 中更新子集合中的文档

I've managed to get and add data to it, but I don't know how to update a document in it. I have the document id of what I need to update. I can't find the update in the docs

答案1

得分: 2

请查看更新文档文档部分。在v9中,应该是:

import { doc, updateDoc } from "firebase/firestore";

const docRef = doc(db, "transactions", "pullout_requests", "requests", "FeLv89oA6vN2wcJAmTo4");

await updateDoc(docRef, {
  capital: true
});
英文:

Checkout update a document section of the documentation. In v9, that should be:

import { doc, updateDoc } from "firebase/firestore";

const docRef = doc(db, "transactions", "pullout_requests", "requests", "FeLv89oA6vN2wcJAmTo4");

await updateDoc(docRef, {
  capital: true
});

huangapple
  • 本文由 发表于 2023年2月10日 04:16:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/75403979.html
匿名

发表评论

匿名网友

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

确定