指南
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 插件目录中, Capgo 的Capacitor 插件 在Capgo 的Capacitor 插件中, 添加或更新插件 在添加或更新插件中, Ionic Enterprise Plugin Alternatives 为 Ionic Enterprise Plugin Alternatives 的产品工作流程 Capgo 原生构建 为 Capgo 原生构建的产品工作流程