指南
关于 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 原生构建中。