Saltare al contenuto

Inizia a utilizzare

Finestra del terminale
bun add @capgo/capacitor-firebase-firestore
bunx cap sync
import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';

Aggiunge un nuovo documento a una raccolta con i dati forniti.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addDocument({} as AddDocumentOptions);

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

Legge il documento indicato dal riferimento specificato.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getDocument({} as GetDocumentOptions);

Aggiorna i campi nel documento indicato dal riferimento specificato.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.updateDocument({} as UpdateDocumentOptions);

Elimina il documento indicato dal riferimento specificato.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.deleteDocument({} as DeleteDocumentOptions);

Esegui più operazioni di scrittura come un singolo batch.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.writeBatch({} as WriteBatchOptions);

Legge la raccolta riferita dal riferimento specificato.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getCollection({} as GetCollectionOptions);

Legge il gruppo di raccolte riferito dal riferimento specificato.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getCollectionGroup({} as GetCollectionGroupOptions);

Recupera il numero di documenti in una raccolta.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.getCountFromServer({} as GetCountFromServerOptions);

Cancella lo storage persistente. Ciò include le scritture pendenti e i documenti memorizzati in cache.

Deve essere chiamato dopo che l'app è stata arrestata o quando l'app viene avviata per la prima volta.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.clearPersistence();

Riabilita l'uso della rete.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.enableNetwork();

Disabilita l'uso della rete.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.disableNetwork();

Instrumenta l'app per comunicare con l'emulatore Firestore.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.useEmulator({} as UseEmulatorOptions);

Aggiunge un ascoltatore per eventi di snapshot documento.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addDocumentSnapshotListener({} as AddDocumentSnapshotListenerOptions, {} as AddDocumentSnapshotListenerCallback<T>);

Aggiunge un ascoltatore per eventi di snapshot raccolta.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addCollectionSnapshotListener({} as AddCollectionSnapshotListenerOptions, {} as AddCollectionSnapshotListenerCallback<T>);

Aggiunge un ascoltatore per eventi di snapshot gruppo raccolta.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.addCollectionGroupSnapshotListener({} as AddCollectionGroupSnapshotListenerOptions, {} as AddCollectionGroupSnapshotListenerCallback<T>);

Rimuovi un ascoltatore per eventi di snapshot documento o raccolta.

import { FirebaseFirestore } from '@capgo/capacitor-firebase-firestore';
await FirebaseFirestore.removeSnapshotListener({} as RemoveSnapshotListenerOptions);
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;
}
export interface AddDocumentResult {
/**
* The reference of the newly added document.
*
* @since 5.2.0
*/
reference: DocumentReference;
}
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;
}
export interface DocumentData {
/**
* A mapping between a field and its value.
*
* @since 5.2.0
*/
[field: string]: any;
}
export interface GetDocumentOptions {
/**
* The reference as a string, with path components separated by a forward slash (`/`).
*
* @since 5.2.0
*/
reference: string;
}
export interface GetDocumentResult<T> {
/**
* The current document contents.
*
* @since 5.2.0
*/
snapshot: DocumentSnapshot<T>;
}
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;
}
export interface DeleteDocumentOptions {
/**
* The reference as a string, with path components separated by a forward slash (`/`).
*
* @since 5.2.0
*/
reference: string;
}
export interface WriteBatchOptions {
/**
* The operations to execute in the batch.
*
* @since 6.1.0
*/
operations: WriteBatchOperation[];
}

GetCollectionOptions

Esegui le opzioni di 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[];
}
export interface GetCollectionResult<T> {
/**
* The documents in the collection.
*
* @since 5.2.0
*/
snapshots: DocumentSnapshot<T>[];
}
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[];
}

Questa pagina è generata dal plugin. src/definitions.tsRiepilogare la sincronizzazione quando le informazioni pubbliche API cambiano in fase di sviluppo.