ガイド
Firebase Firestoreのチュートリアル
capgo/capacitor-firebase-firestoreを使用
CapacitorのFirebase Cloud Firestore プラグイン
インストール
bun add @capgo/capacitor-firebase-firestore
bunx cap sync
このプラグインが公開するもの
addDocument- 指定されたデータでコレクションに新しいドキュメントを追加します。setDocument- 指定された参照に記載されているドキュメントに書き込む。ドキュメントがまだ存在しない場合、ドキュメントが作成されます。getDocument- 指定された参照に記載されているドキュメントを読み取ります。updateDocument- 指定された参照に記載されているドキュメントのフィールドを更新します。
例外使用
addDocument
__CAPGO_KEEP_0__のデータをもとに、指定されたコレクションに新しいドキュメントを追加します。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addDocument({} as AddDocumentOptions);
setDocument
__CAPGO_KEEP_0__に記述された参照をもとに、ドキュメントに書き込みます。ドキュメントがまだ存在しない場合、作成されます。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.setDocument({} as SetDocumentOptions);
getDocument
__CAPGO_KEEP_0__に記述された参照をもとに、ドキュメントを読み取ります。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getDocument({} as GetDocumentOptions);
updateDocument
__CAPGO_KEEP_0__に記述された参照をもとに、ドキュメントのフィールドを更新します。
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/