はじめに
このプラグインのインストール手順とフル マークダウン ガイドを含むセットアップの質問をコピーできます。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-firebase-firestore`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/firebase-firestore/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
インストール
Installを実行するbun add @capgo/capacitor-firebase-firestorebunx cap syncインポート
インポートを実行するimport { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';APIの概要
APIの概要を実行するaddDocument
addDocument__CAPGO_KEEP_0__を使用して指定されたデータでコレクションに新しいドキュメントを追加します。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addDocument({} as AddDocumentOptions);setDocument
setDocument指定された参照に記述されるドキュメントに書き込む。 ドキュメントがまだ存在しない場合、作成される。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.setDocument({} as SetDocumentOptions);getDocument
「getDocument」セクション指定された参照に記述されるドキュメントを読み取る。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getDocument({} as GetDocumentOptions);updateDocument
「updateDocument」セクション指定された参照に記述されるドキュメントのフィールドを更新する。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.updateDocument({} as UpdateDocumentOptions);deleteDocument
「deleteDocument」セクション指定された参照に記述されるドキュメントを削除する。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.deleteDocument({} as DeleteDocumentOptions);writeBatch
「writeBatch」セクション複数の書き込み操作を 1 つのバッチとして実行します。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.writeBatch({} as WriteBatchOptions);getCollection
セクション “getCollection”指定された参照に基づいて参照されるコレクションを読み取ります。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getCollection({} as GetCollectionOptions);getCollectionGroup
セクション “getCollectionGroup”指定された参照に基づいて参照されるコレクション グループを読み取ります。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getCollectionGroup({} as GetCollectionGroupOptions);getCountFromServer
セクション “getCountFromServer”サーバーからドキュメントの数を取得します。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getCountFromServer({} as GetCountFromServerOptions);clearPersistence
セクション “clearPersistence”__CAPGO_KEEP_0__を永続的に消去します。この処理には、書き込みの保留中とキャッシュされたドキュメントが含まれます。
アプリがシャットダウンした後またはアプリが初めて初期化された後には、必ず呼び出してください。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.clearPersistence();enableNetwork
ネットワークの使用を有効化するセクションネットワークの使用を再度有効化します。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.enableNetwork();disableNetwork
ネットワークの使用を無効化するセクションネットワークの使用を無効化します。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.disableNetwork();useEmulator
エミュレータを使用するセクションアプリをインストルメントして、Firestore エミュレータと通信するようにします。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.useEmulator({} as UseEmulatorOptions);addDocumentSnapshotListener
「addDocumentSnapshotListener」セクションドキュメント スナップショット イベントのリスナーを追加します。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addDocumentSnapshotListener({} as AddDocumentSnapshotListenerOptions, {} as AddDocumentSnapshotListenerCallback<T>);addCollectionSnapshotListener
「addCollectionSnapshotListener」セクションコレクション スナップショット イベントのリスナーを追加します。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addCollectionSnapshotListener({} as AddCollectionSnapshotListenerOptions, {} as AddCollectionSnapshotListenerCallback<T>);addCollectionGroupSnapshotListener
「addCollectionGroupSnapshotListener」セクションコレクション グループ スナップショット イベントのリスナーを追加します。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addCollectionGroupSnapshotListener({} as AddCollectionGroupSnapshotListenerOptions, {} as AddCollectionGroupSnapshotListenerCallback<T>);removeSnapshotListener
「removeSnapshotListener」セクションドキュメントまたはコレクション スナップショット イベントのリスナーを削除します。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.removeSnapshotListener({} as RemoveSnapshotListenerOptions);種類の参照
種類の参照AddDocumentOptions
ドキュメントの追加のオプションexport interface AddDocumentOptions { /** * The reference as a string, with path components separated by a forward slash (`/`). * * @since 5.2.0 * @example 'users' */ reference: string; /** * An object containing the data for the new document. * * @since 5.2.0 * @example { first: 'Alan', last: 'Turing', born: 1912 } */ data: DocumentData;}AddDocumentResult
ドキュメントの追加の結果export interface AddDocumentResult { /** * The reference of the newly added document. * * @since 5.2.0 */ reference: DocumentReference;}SetDocumentOptions
ドキュメントの設定のオプションexport interface SetDocumentOptions { /** * The reference as a string, with path components separated by a forward slash (`/`). * * @since 5.2.0 * @example 'users/Aorq09lkt1ynbR7xhTUx' */ reference: string; /** * An object containing the data for the new document. * * @since 5.2.0 * @example { first: 'Alan', last: 'Turing', born: 1912 } */ data: DocumentData; /** * Whether to merge the provided data with an existing document. * * @since 5.2.0 * @example true * @default false */ merge?: boolean;}DocumentData
ドキュメントのデータexport interface DocumentData { /** * A mapping between a field and its value. * * @since 5.2.0 */ [field: string]: any;}GetDocumentOptions
ドキュメントの取得のオプションexport interface GetDocumentOptions { /** * The reference as a string, with path components separated by a forward slash (`/`). * * @since 5.2.0 */ reference: string;}GetDocumentResult
「GetDocumentResult」セクションexport interface GetDocumentResult<T> { /** * The current document contents. * * @since 5.2.0 */ snapshot: DocumentSnapshot<T>;}UpdateDocumentOptions
「UpdateDocumentOptions」セクションexport interface UpdateDocumentOptions { /** * The reference as a string, with path components separated by a forward slash (`/`). * * @since 5.2.0 */ reference: string; /** * An object containing the data for the new document. * * @since 5.2.0 * @example { first: 'Alan', last: 'Turing', born: 1912 } */ data: DocumentData;}DeleteDocumentOptions
「DeleteDocumentOptions」セクションexport interface DeleteDocumentOptions { /** * The reference as a string, with path components separated by a forward slash (`/`). * * @since 5.2.0 */ reference: string;}WriteBatchOptions
「WriteBatchOptions」セクションexport interface WriteBatchOptions { /** * The operations to execute in the batch. * * @since 6.1.0 */ operations: WriteBatchOperation[];}GetCollectionOptions
「GetCollectionOptions」セクションexport interface GetCollectionOptions { /** * The reference as a string, with path components separated by a forward slash (`/`). * * @since 5.2.0 */ reference: string; /** * The filter to apply. * * @since 5.2.0 */ compositeFilter?: QueryCompositeFilterConstraint; /** * Narrow or order the set of documents to retrieve, but do not explicitly filter for document fields. * * @since 5.2.0 */ queryConstraints?: QueryNonFilterConstraint[];}GetCollectionResult
「GetCollectionResult」セクションexport interface GetCollectionResult<T> { /** * The documents in the collection. * * @since 5.2.0 */ snapshots: DocumentSnapshot<T>[];}GetCollectionGroupOptions
「GetCollectionGroupOptions」セクションexport interface GetCollectionGroupOptions { /** * The reference as a string, with path components separated by a forward slash (`/`). * * @since 5.2.0 */ reference: string; /** * The filter to apply. * * @since 5.2.0 */ compositeFilter?: QueryCompositeFilterConstraint; /** * Narrow or order the set of documents to retrieve, but do not explicitly filter for document fields. * * @since 5.2.0 */ queryConstraints?: QueryNonFilterConstraint[];}真実の源
「真実の源」セクションこのページはプラグインから生成されています。 src/definitions.tsパブリック API がアップストリームで変更された場合、再度同期を実行してください。