UNPKG

@nativescript/firebase-firestore

Version:
302 lines (301 loc) 14.8 kB
import { GetOptions, DocumentChangeType } from './common'; export { GetOptions, DocumentChangeType }; import { WhereFilterOp, ICollectionReference, IDocumentReference, IFieldPath, IFieldValue, IGeoPoint, IQuery, ITimestamp, IWriteBatch, SetOptions, DocumentData, IDocumentSnapshot, IQuerySnapshot, SnapshotListenOptions, ISnapshotMetadata, IDocumentChange, IQueryDocumentSnapshot, ITransaction, ISettings, IFirestore, IBytes, DocumentFieldType } from '.'; import { FirebaseApp } from '@nativescript/firebase-core'; export declare class Transaction implements ITransaction { _native: com.google.firebase.firestore.Transaction; static fromNative(transaction: com.google.firebase.firestore.Transaction): Transaction; delete<T extends DocumentData = DocumentData>(documentRef: DocumentReference): Transaction; get<T extends DocumentData = DocumentData>(documentRef: DocumentReference<T>): Promise<DocumentSnapshot<T>>; update<T extends DocumentData = DocumentData>(documentRef: DocumentReference<T>, data: Partial<{ [K in keyof T]: T[K] | FieldValue; }>): Transaction; update<T extends DocumentData = DocumentData, K extends keyof T = string>(documentRef: DocumentReference<T>, field: K | FieldPath, value: T[K], moreFieldsAndValues: any[]): Transaction; set<T extends DocumentData = DocumentData>(documentRef: DocumentReference<T>, data: T, options?: SetOptions): Transaction; get android(): com.google.firebase.firestore.Transaction; get native(): com.google.firebase.firestore.Transaction; } export declare class SnapshotMetadata implements ISnapshotMetadata { _native: com.google.firebase.firestore.SnapshotMetadata; static fromNative(metadata: com.google.firebase.firestore.SnapshotMetadata): SnapshotMetadata; get fromCache(): boolean; get hasPendingWrites(): boolean; toJSON(): { fromCache: boolean; hasPendingWrites: boolean; }; get native(): com.google.firebase.firestore.SnapshotMetadata; get android(): com.google.firebase.firestore.SnapshotMetadata; } export declare class DocumentSnapshot<T extends DocumentData = DocumentData> implements IDocumentSnapshot<T> { _native: com.google.firebase.firestore.DocumentSnapshot; static fromNative(snapshot: com.google.firebase.firestore.DocumentSnapshot): DocumentSnapshot<DocumentData>; get exists(): boolean; get id(): string; get metadata(): SnapshotMetadata; get ref(): DocumentReference; data(): any; get<fieldType extends DocumentFieldType>(fieldPath: string | number | FieldPath): fieldType; toJSON(): { exists: boolean; id: string; metadata: SnapshotMetadata; ref: DocumentReference<DocumentData>; data: () => any; }; get native(): com.google.firebase.firestore.DocumentSnapshot; get android(): com.google.firebase.firestore.DocumentSnapshot; } export declare class DocumentChange implements IDocumentChange { _native: com.google.firebase.firestore.DocumentChange; static fromNative(change: com.google.firebase.firestore.DocumentChange): DocumentChange; get doc(): QueryDocumentSnapshot<DocumentData>; get newIndex(): number; get oldIndex(): number; get type(): DocumentChangeType; toJSON(): { doc: QueryDocumentSnapshot<DocumentData>; newIndex: number; oldIndex: number; type: DocumentChangeType; }; get native(): com.google.firebase.firestore.DocumentChange; get android(): com.google.firebase.firestore.DocumentChange; } export declare class Query<T extends DocumentData = DocumentData> implements IQuery<T> { _native: com.google.firebase.firestore.Query; static fromNative(query: com.google.firebase.firestore.Query): Query; endAt(snapshot: DocumentSnapshot<T>): Query; endAt(fieldValues: FieldValue[]): Query; endBefore(snapshot: DocumentSnapshot<T>): Query; endBefore(fieldValues: FieldValue[]): Query; get(options?: GetOptions): Promise<QuerySnapshot>; limit(limit: number): Query<DocumentData>; limitToLast(limitToLast: number): Query<DocumentData>; onSnapshot(observer: { complete?: () => void; error?: (error: Error) => void; next?: (snapshot: QuerySnapshot) => void; }): () => void; onSnapshot(options: SnapshotListenOptions, observer: { complete?: () => void; error?: (error: Error) => void; next?: (snapshot: QuerySnapshot) => void; }): () => void; onSnapshot(onNext: (snapshot: QuerySnapshot) => void, onError?: (error: Error) => void, onCompletion?: () => void): () => void; onSnapshot(options: SnapshotListenOptions, onNext: (snapshot: QuerySnapshot) => void, onError?: (error: Error) => void, onCompletion?: () => void): () => void; orderBy(fieldPath: keyof DocumentData | FieldPath, directionStr?: 'asc' | 'desc'): Query; startAfter(snapshot: DocumentSnapshot<T>): Query; startAfter(fieldValues: FieldValue[]): Query; startAt(snapshot: DocumentSnapshot<T>): Query; startAt(fieldValues: FieldValue[]): Query; where(fieldPath: FieldPath | keyof DocumentData, opStr: WhereFilterOp, value: any): Query; isEqual(other: Query): boolean; get native(): com.google.firebase.firestore.Query; get android(): com.google.firebase.firestore.Query; } export declare class QueryDocumentSnapshot<T extends DocumentData = DocumentData> extends DocumentSnapshot<T> implements IQueryDocumentSnapshot<T> { _native: com.google.firebase.firestore.DocumentSnapshot; static fromNative(snapshot: com.google.firebase.firestore.DocumentSnapshot): QueryDocumentSnapshot<DocumentData>; data(): any; get<fieldType extends DocumentFieldType>(fieldPath: string | number | FieldPath): fieldType; get native(): com.google.firebase.firestore.DocumentSnapshot; get android(): com.google.firebase.firestore.DocumentSnapshot; } export declare class QuerySnapshot implements IQuerySnapshot { _native: com.google.firebase.firestore.QuerySnapshot; static fromNative(snapshot: com.google.firebase.firestore.QuerySnapshot): QuerySnapshot; get docs(): any[]; get empty(): boolean; get metadata(): SnapshotMetadata; get query(): Query<DocumentData>; get size(): number; docChanges(options?: SnapshotListenOptions): DocumentChange[]; forEach(callback: (result: QueryDocumentSnapshot, index: number) => void, thisArg?: any): void; toJSON(): { docs: any[]; empty: boolean; metadata: SnapshotMetadata; size: number; }; get native(): com.google.firebase.firestore.QuerySnapshot; get android(): com.google.firebase.firestore.QuerySnapshot; } export declare class CollectionReference<T extends DocumentData = DocumentData> extends Query<T> implements ICollectionReference<T> { _native: com.google.firebase.firestore.CollectionReference; static fromNative(collection: com.google.firebase.firestore.CollectionReference): CollectionReference<DocumentData>; get id(): string; get parent(): DocumentReference; get path(): string; add(data: T): Promise<DocumentReference<T>>; doc(documentPath?: string): DocumentReference<DocumentData>; toJSON(): { id: string; path: string; parent: DocumentReference<DocumentData>; }; get native(): com.google.firebase.firestore.CollectionReference; get android(): com.google.firebase.firestore.CollectionReference; } export declare class DocumentReference<T extends DocumentData = DocumentData> implements IDocumentReference<T> { _native: com.google.firebase.firestore.DocumentReference; static fromNative(document: com.google.firebase.firestore.DocumentReference): DocumentReference<DocumentData>; get firestore(): Firestore; get id(): string; get parent(): CollectionReference<DocumentData>; get path(): string; collection(collectionPath: string): CollectionReference<DocumentData>; delete(): Promise<void>; get(options?: GetOptions): Promise<DocumentSnapshot<T>>; onSnapshot(observer: { complete?: () => void; error?: (error: Error) => void; next?: (snapshot: DocumentSnapshot<T>) => void; }): () => void; onSnapshot(options: SnapshotListenOptions, observer: { complete?: () => void; error?: (error: Error) => void; next?: (snapshot: DocumentSnapshot<T>) => void; }): () => void; onSnapshot(onNext: (snapshot: DocumentSnapshot<T>) => void, onError?: (error: Error) => void, onCompletion?: () => void): () => void; onSnapshot(options: SnapshotListenOptions, onNext: (snapshot: DocumentSnapshot<T>) => void, onError?: (error: Error) => void, onCompletion?: () => void): () => void; set(data: T, options?: SetOptions): Promise<void>; update(data: Partial<{ [K in keyof T]: FieldValue | T[K]; }>): Promise<void>; update(field: FieldPath | keyof T, value: any, moreFieldsAndValues: any[]): Promise<void>; toJSON(): { id: string; path: string; parent: CollectionReference<DocumentData>; }; get native(): com.google.firebase.firestore.DocumentReference; get android(): com.google.firebase.firestore.DocumentReference; } export declare class FieldPath implements IFieldPath { _native: com.google.firebase.firestore.FieldPath; constructor(fieldNames: string[], native?: boolean); static fromNative(field: com.google.firebase.firestore.FieldPath): FieldPath; get native(): com.google.firebase.firestore.FieldPath; get android(): com.google.firebase.firestore.FieldPath; static documentId(): FieldPath; toString(): string; } export declare class FieldValue implements IFieldValue { _native: com.google.firebase.firestore.FieldValue; static fromNative(field: com.google.firebase.firestore.FieldValue): FieldValue; static arrayRemove(elements: any[]): FieldValue; static arrayUnion(elements: any[]): FieldValue; static delete(): FieldValue; static increment(n: number): FieldValue; static serverTimestamp(): FieldValue; get native(): com.google.firebase.firestore.FieldValue; get android(): com.google.firebase.firestore.FieldValue; } export declare class GeoPoint implements IGeoPoint { _native: com.google.firebase.firestore.GeoPoint; constructor(latitude: number, longitude: number, native?: boolean); static fromNative(point: com.google.firebase.firestore.GeoPoint): GeoPoint; get latitude(): number; get longitude(): number; get native(): com.google.firebase.firestore.GeoPoint; get android(): com.google.firebase.firestore.GeoPoint; toJSON(): { latitude: number; longitude: number; }; } export declare class Timestamp implements ITimestamp { _native: com.google.firebase.Timestamp; constructor(seconds: number, nanoseconds: number, native?: boolean); static fromNative(timestamp: com.google.firebase.Timestamp): Timestamp; static _dateFormat: java.text.SimpleDateFormat; static fromDate(date: Date): Timestamp; static fromMillis(milliseconds: number): Timestamp; static now(): Timestamp; isEqual(ts: Timestamp): boolean; toDate(): Date; toMillis(): number; valueOf(): string; get nanoseconds(): number; get seconds(): number; get native(): com.google.firebase.Timestamp; get android(): com.google.firebase.Timestamp; toJSON(): { nanoseconds: number; seconds: number; }; } export declare class WriteBatch implements IWriteBatch { _native: com.google.firebase.firestore.WriteBatch; static fromNative(batch: com.google.firebase.firestore.WriteBatch): WriteBatch; commit(): Promise<void>; delete(documentRef: DocumentReference): WriteBatch; set(documentRef: DocumentReference, data: DocumentData, options?: SetOptions): WriteBatch; get native(): com.google.firebase.firestore.WriteBatch; get android(): com.google.firebase.firestore.WriteBatch; update<T extends DocumentData = DocumentData>(documentRef: DocumentReference<T>, data: Partial<{ [K in keyof T]: T[K] | FieldValue; }>): WriteBatch; update<T extends DocumentData = DocumentData, K extends keyof T = string>(documentRef: DocumentReference<T>, field: K | FieldPath, value: FieldValue | T[K], moreFieldAndValues: any[]): WriteBatch; } export declare class Settings implements ISettings { _builder: com.google.firebase.firestore.FirebaseFirestoreSettings.Builder; _firestore: com.google.firebase.firestore.FirebaseFirestore; constructor(); static fromNative(ffs: com.google.firebase.firestore.FirebaseFirestoreSettings, firestore?: any): Settings; _updateStoreSettings(): void; get cacheSizeBytes(): number; set cacheSizeBytes(value: number); get host(): string; set host(value: string); ignoreUndefinedProperties: boolean; get persistence(): boolean; set persistence(value: boolean); get ssl(): boolean; set ssl(value: boolean); toJSON(): { cacheSizeBytes: number; host: string; ignoreUndefinedProperties: boolean; persistence: boolean; ssl: boolean; }; get android(): com.google.firebase.firestore.FirebaseFirestoreSettings; get native(): com.google.firebase.firestore.FirebaseFirestoreSettings; } export declare class Bytes implements IBytes { _native: com.google.firebase.firestore.Blob; static fromNative(data: com.google.firebase.firestore.Blob): Bytes; static fromBase64String(base64: any): Bytes; static fromUint8Array(array: any): Bytes; _base64: string; toBase64(): string; _native_buffer: any; _buffer: any; toUint8Array(): Uint8Array; get native(): com.google.firebase.firestore.Blob; get android(): com.google.firebase.firestore.Blob; } export declare class Firestore implements IFirestore { _native: com.google.firebase.firestore.FirebaseFirestore; _app: FirebaseApp; constructor(app?: FirebaseApp); useEmulator(host: string, port: number): void; static fromNative(store: com.google.firebase.firestore.FirebaseFirestore): Firestore; batch(): WriteBatch; collection(collectionPath: string): CollectionReference; clearPersistence(): Promise<void>; collectionGroup(collectionId: string): Query; disableNetwork(): Promise<void>; doc(documentPath: string): DocumentReference; enableNetwork(): Promise<void>; runTransaction(updateFunction: (transaction: Transaction) => Promise<any>): Promise<any>; get settings(): Settings; set settings(value: Settings); terminate(): Promise<void>; waitForPendingWrites(): Promise<void>; get native(): com.google.firebase.firestore.FirebaseFirestore; get android(): com.google.firebase.firestore.FirebaseFirestore; get app(): FirebaseApp; }