__CAPGO_KEEP_0__ logo
返回插件
@capgo/capacitor-firebase-firestore
教程
由 github.com/Cap-go

Firebase Firestore

Capacitor 对 Firebase Cloud Firestore 的插件

指南

关于 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);

全局参考