Getting Started
Copy a setup prompt with the install steps and the full markdown guide for this plugin.
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
Section titled “Install”You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins次に、以下のプロンプトを使用してください:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-firebase-firestore` plugin in my project.Manual Setupを使用する場合は、以下のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください:
bun add @capgo/capacitor-firebase-firestorebunx cap syncインポート
「インポート」のセクションimport { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';APIの概要
「APIの概要」のセクションaddDocument
Section titled “addDocument”Adds a new document to a collection with the given data.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addDocument({} as AddDocumentOptions);setDocument
Section titled “setDocument”Writes to the document referred to by the specified reference. If the document does not yet exist, it will be created.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.setDocument({} as SetDocumentOptions);getDocument
Section titled “getDocument”Reads the document referred to by the specified reference.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getDocument({} as GetDocumentOptions);updateDocument
Section titled “updateDocument”Updates fields in the document referred to by the specified reference.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.updateDocument({} as UpdateDocumentOptions);deleteDocument
Section titled “deleteDocument”指定された参照で示されるドキュメントを削除します。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.deleteDocument({} as DeleteDocumentOptions);writeBatch
Section titled “writeBatch”複数の書き込み操作を単一のバッチとして実行します。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.writeBatch({} as WriteBatchOptions);getCollection
Section titled “getCollection”指定された参照で示されるコレクションを読み取ります。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getCollection({} as GetCollectionOptions);getCollectionGroup
Section titled “getCollectionGroup”指定された参照で示されるコレクション グループを読み取ります。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getCollectionGroup({} as GetCollectionGroupOptions);getCountFromServer
Section titled “getCountFromServer”サーバーからドキュメントの数を取得します。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getCountFromServer({} as GetCountFromServerOptions);clearPersistence
Section titled “clearPersistence”アプリが終了した後またはアプリが初めて起動された後、キャッシュされたドキュメントや書き込みを含む永続的ストレージをクリアします。
Must be called after the app is shutdown or when the app is first initialized.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.clearPersistence();enableNetwork
Section titled “enableNetwork”ネットワークの使用を再度許可します。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.enableNetwork();disableNetwork
Section titled “disableNetwork”ネットワークの使用を禁止します。
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.disableNetwork();useEmulator
__CAPGO_KEEP_1____CAPGO_KEEP_2__
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.useEmulator({} as UseEmulatorOptions);addDocumentSnapshotListener
__CAPGO_KEEP_1____CAPGO_KEEP_3__
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addDocumentSnapshotListener({} as AddDocumentSnapshotListenerOptions, {} as AddDocumentSnapshotListenerCallback<T>);addCollectionSnapshotListener
__CAPGO_KEEP_1____CAPGO_KEEP_4__
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addCollectionSnapshotListener({} as AddCollectionSnapshotListenerOptions, {} as AddCollectionSnapshotListenerCallback<T>);addCollectionGroupSnapshotListener
__CAPGO_KEEP_1____CAPGO_KEEP_5__
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
DocumentDataセクションexport interface DocumentData { /** * A mapping between a field and its value. * * @since 5.2.0 */ [field: string]: any;}GetDocumentOptions
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
Section titled “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
Section titled “GetCollectionResult”export interface GetCollectionResult<T> { /** * The documents in the collection. * * @since 5.2.0 */ snapshots: DocumentSnapshot<T>[];}GetCollectionGroupOptions
Section titled “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.tsAPIがアップストリームで変更されたときは、再度同期を実行してください。
Getting Startedから続けて
Section titled “Getting Startedから続けて”If you are using Getting Started ダッシュボードとAPIの運用計画を行うには APIの概要 APIの概要の実装詳細については 導入 導入の実装詳細については APIのキー APIのキーに関する実装詳細については デバイス デバイスに関する実装詳細については バンドル __CAPGO_KEEP_0__の実装詳細については、Bundlesにあります。