Iniziare
Copia un prompt di configurazione con le istruzioni di installazione e la guida markdown completa per questo 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.
Puoi utilizzare la nostra configurazione assistita da AI per installare il plugin. Aggiungi le Capgo competenze al tuo strumento AI utilizzando il seguente comando:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-pluginsPoi utilizza la seguente richiesta:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-firebase-firestore` plugin in my project.Se preferisci la configurazione manuale, installa il plugin eseguendo i seguenti comandi e segui le istruzioni specifiche per la piattaforma riportate di seguito:
bun add @capgo/capacitor-firebase-firestorebunx cap syncimport { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';API Panoramica
Sezione intitolata “API Panoramica”addDocument
Sezione intitolata “aggiungiDocumento”Aggiunge un nuovo documento a una raccolta con i dati specificati.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addDocument({} as AddDocumentOptions);setDocument
Sezione intitolata “impostaDocumento”Scrive nel documento indicato dal riferimento specificato. Se il documento non esiste ancora, verrà creato.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.setDocument({} as SetDocumentOptions);getDocument
Sezione intitolata “ottieneDocumento”Legge il documento indicato dal riferimento specificato.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getDocument({} as GetDocumentOptions);updateDocument
Sezione intitolata “aggiornaDocumento”Aggiorna i campi del documento indicato dalla specifica referenza.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.updateDocument({} as UpdateDocumentOptions);deleteDocument
Sottosezione intitolata “elimina documento”Elimina il documento indicato dalla specifica referenza.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.deleteDocument({} as DeleteDocumentOptions);writeBatch
Sottosezione intitolata “scrivi batch”Esegui operazioni di scrittura multiple come un batch unico.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.writeBatch({} as WriteBatchOptions);getCollection
Sottosezione intitolata “ottiene raccolta”Legge la raccolta indicata dalla specifica referenza.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getCollection({} as GetCollectionOptions);getCollectionGroup
Sottosezione intitolata “ottiene raccolta di gruppo”Legge il gruppo di raccolta di cui è stato specificato il riferimento.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getCollectionGroup({} as GetCollectionGroupOptions);getCountFromServer
Sottosezione intitolata “getCountFromServer”Estrae il numero di documenti in una raccolta.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getCountFromServer({} as GetCountFromServerOptions);clearPersistence
Sottosezione intitolata “clearPersistence”Elimina lo storage persistente. Ciò include scritture pendenti e documenti memorizzati in cache.
Deve essere chiamato dopo che l'app è stata chiusa o all'avvio dell'app per la prima volta.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.clearPersistence();enableNetwork
Sottosezione intitolata “enableNetwork”Riabilita l'uso della rete.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.enableNetwork();disableNetwork
Sezione intitolata “disabilitaRete”Disabilita l'uso della rete.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.disableNetwork();useEmulator
Sezione intitolata “utilizzaEmulatore”Instrumenta il tuo app per comunicare con l'emulatore Firestore.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.useEmulator({} as UseEmulatorOptions);addDocumentSnapshotListener
Sezione intitolata “aggiungiAscoltatoreSnapshotDocumento”Aggiunge un ascoltatore per eventi snapshot documento.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addDocumentSnapshotListener({} as AddDocumentSnapshotListenerOptions, {} as AddDocumentSnapshotListenerCallback<T>);addCollectionSnapshotListener
Sezione intitolata “aggiungiAscoltatoreSnapshotCollezione”Aggiunge un ascoltatore per eventi snapshot collezione.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addCollectionSnapshotListener({} as AddCollectionSnapshotListenerOptions, {} as AddCollectionSnapshotListenerCallback<T>);addCollectionGroupSnapshotListener
Sezione intitolata “addCollectionGroupSnapshotListener”Aggiunge un ascoltatore per eventi snapshot di gruppi di raccolta.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addCollectionGroupSnapshotListener({} as AddCollectionGroupSnapshotListenerOptions, {} as AddCollectionGroupSnapshotListenerCallback<T>);removeSnapshotListener
Sezione intitolata “removeSnapshotListener”Elimina un ascoltatore per eventi snapshot di documenti o raccolte.
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.removeSnapshotListener({} as RemoveSnapshotListenerOptions);Riferimento di tipo
Sezione intitolata “Riferimento di tipo”AddDocumentOptions
Sezione intitolata “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
Sezione intitolata “AddDocumentResult”export interface AddDocumentResult { /** * The reference of the newly added document. * * @since 5.2.0 */ reference: DocumentReference;}SetDocumentOptions
Sezione intitolata “Imposta le opzioni del documento”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
Sezione intitolata “Dati del documento”export interface DocumentData { /** * A mapping between a field and its value. * * @since 5.2.0 */ [field: string]: any;}GetDocumentOptions
Sezione intitolata “Ottieni le opzioni del documento”export interface GetDocumentOptions { /** * The reference as a string, with path components separated by a forward slash (`/`). * * @since 5.2.0 */ reference: string;}GetDocumentResult
Sezione intitolata “Risultato del documento”export interface GetDocumentResult<T> { /** * The current document contents. * * @since 5.2.0 */ snapshot: DocumentSnapshot<T>;}UpdateDocumentOptions
Sezione intitolata “Aggiorna le opzioni del documento”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
Sezione intitolata “Elimina le opzioni del documento”export interface DeleteDocumentOptions { /** * The reference as a string, with path components separated by a forward slash (`/`). * * @since 5.2.0 */ reference: string;}WriteBatchOptions
Sezione intitolata “Opzioni di scrittura batch”export interface WriteBatchOptions { /** * The operations to execute in the batch. * * @since 6.1.0 */ operations: WriteBatchOperation[];}GetCollectionOptions
Sezione intitolata “Opzioni di lettura di una raccolta”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
Sezione intitolata “Risultato di lettura di una raccolta”export interface GetCollectionResult<T> { /** * The documents in the collection. * * @since 5.2.0 */ snapshots: DocumentSnapshot<T>[];}GetCollectionGroupOptions
Sezione intitolata “Opzioni di lettura di un gruppo di raccolte”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[];}Fonte di verità
Sezione intitolata “Fonte di verità”Questa pagina è generata dal plugin’s src/definitions.ts. Riavvia la sincronizzazione quando il pubblico API cambia in modo upstream.
Continua da Inizia
Sezione intitolata “Continua da Inizia”Se stai utilizzando Inizia per pianificare dashboard e API operazioni, connettilo con API Overview per i dettagli di implementazione in API Overview, Introduzione per i dettagli di implementazione in Introduzione, API Keys per i dettagli di implementazione in API Keys, Dispositivi per i dettagli di implementazione nei dispositivi, e Pacchetti per i dettagli di implementazione nei Pacchetti.