指南
如何在 Capacitor 中使用 Firebase Firestore
使用@capgo/capacitor-firebase-firestore
Capacitor插件用于Firebase Cloud Firestore。
安装
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 插件目录中的产品工作流程 Capacitor 由Capgo 提供 为 Capacitor 插件的实现细节提供了 Capgo 的支持。 添加或更新插件 为添加或更新插件的实现细节 Ionic 企业插件替代品 为 Ionic 企业插件替代品的产品工作流程 Capgo 原生构建 为 Capgo 原生构建的产品工作流程