指南
如何在 Capacitor 中使用 Firebase Firestore
使用 @capgo/capacitor-firebase-firestore
适用于 Firebase Cloud Firestore 的 Capacitor 插件。
安装
bun add @capgo/capacitor-firebase-firestore
bunx cap sync
插件暴露的内容
addDocument- 向集合中添加带有给定数据的新文档。setDocument- 写入指定引用指向的文档。如果文档尚不存在,则会创建该文档。getDocument- 读取指定引用指向的文档。updateDocument- 更新指定引用所指向文档中的字段。
用法示例
addDocument
向集合中添加包含给定数据的新文档。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addDocument({} as AddDocumentOptions);
setDocument
写入指定引用所指向的文档。如果文档尚不存在,则会创建该文档。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.setDocument({} as SetDocumentOptions);
getDocument
读取指定引用所指向的文档。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getDocument({} as GetDocumentOptions);
updateDocument
更新指定引用所指向文档中的字段。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.updateDocument({} as UpdateDocumentOptions);
完整参考
- GitHub: https://github.com/Cap-go/capacitor-firebase/tree/main/packages/firestore
- 文档: /docs/plugins/firebase-firestore/
继续阅读:使用 @capgo/capacitor-firebase-firestore
如果你正在使用 使用 @capgo/capacitor-firebase-firestore 要规划原生插件工作,请将其与 Capgo 插件目录 查看 Capgo 插件目录中的产品工作流, Capgo 提供的 Capacitor 插件 查看由 Capgo 提供的 Capacitor 插件中的实现细节, 添加或更新插件 查看添加或更新插件中的实现细节, Ionic Enterprise 插件替代方案 查看 Ionic Enterprise 插件替代方案中的产品工作流,以及 Capgo Native Build 查看 Capgo Native Builds 中的产品工作流。