[firestore][typings] A few tweaks to match documentation
This commit is contained in:
parent
a03c445e0c
commit
4c75e188f7
|
@ -6,9 +6,11 @@ import DocumentReference from './DocumentReference';
|
|||
import Query from './Query';
|
||||
import { firestoreAutoId } from '../../utils';
|
||||
|
||||
import type DocumentSnapshot from './DocumentSnapshot';
|
||||
import type Firestore from './';
|
||||
import type { FirestoreQueryDirection, FirestoreQueryOperator } from '../../types';
|
||||
import type Path from './Path';
|
||||
import type { Observer, QueryListenOptions } from './Query';
|
||||
import type QuerySnapshot from './QuerySnapshot';
|
||||
|
||||
/**
|
||||
|
@ -19,13 +21,13 @@ export default class CollectionReference {
|
|||
_firestore: Firestore;
|
||||
_query: Query;
|
||||
|
||||
constructor(firestore: Object, collectionPath: Path) {
|
||||
constructor(firestore: Firestore, collectionPath: Path) {
|
||||
this._collectionPath = collectionPath;
|
||||
this._firestore = firestore;
|
||||
this._query = new Query(firestore, collectionPath);
|
||||
}
|
||||
|
||||
get firestore(): Object {
|
||||
get firestore(): Firestore {
|
||||
return this._firestore;
|
||||
}
|
||||
|
||||
|
@ -56,36 +58,40 @@ export default class CollectionReference {
|
|||
}
|
||||
|
||||
// From Query
|
||||
endAt(fieldValues: any): Query {
|
||||
return this._query.endAt(fieldValues);
|
||||
endAt(...snapshotOrVarArgs: any[]): Query {
|
||||
return this._query.endAt(snapshotOrVarArgs);
|
||||
}
|
||||
|
||||
endBefore(fieldValues: any): Query {
|
||||
return this._query.endBefore(fieldValues);
|
||||
endBefore(...snapshotOrVarArgs: any[]): Query {
|
||||
return this._query.endBefore(snapshotOrVarArgs);
|
||||
}
|
||||
|
||||
get(): Promise<QuerySnapshot> {
|
||||
return this._query.get();
|
||||
}
|
||||
|
||||
limit(n: number): Query {
|
||||
return this._query.limit(n);
|
||||
limit(limit: number): Query {
|
||||
return this._query.limit(limit);
|
||||
}
|
||||
|
||||
onSnapshot(onNext: () => any, onError?: () => any): () => void {
|
||||
return this._query.onSnapshot(onNext, onError);
|
||||
onSnapshot(
|
||||
optionsOrObserverOrOnNext: QueryListenOptions | Observer | (DocumentSnapshot) => void,
|
||||
observerOrOnNextOrOnError?: Observer | (DocumentSnapshot) => void | (Object) => void,
|
||||
onError?: (Object) => void,
|
||||
): () => void {
|
||||
return this._query.onSnapshot(optionsOrObserverOrOnNext, observerOrOnNextOrOnError, onError);
|
||||
}
|
||||
|
||||
orderBy(fieldPath: string, directionStr?: FirestoreQueryDirection): Query {
|
||||
return this._query.orderBy(fieldPath, directionStr);
|
||||
}
|
||||
|
||||
startAfter(fieldValues: any): Query {
|
||||
return this._query.startAfter(fieldValues);
|
||||
startAfter(...snapshotOrVarArgs: any[]): Query {
|
||||
return this._query.startAfter(snapshotOrVarArgs);
|
||||
}
|
||||
|
||||
startAt(fieldValues: any): Query {
|
||||
return this._query.startAt(fieldValues);
|
||||
startAt(...snapshotOrVarArgs: any[]): Query {
|
||||
return this._query.startAt(snapshotOrVarArgs);
|
||||
}
|
||||
|
||||
where(fieldPath: string, opStr: FirestoreQueryOperator, value: any): Query {
|
||||
|
|
|
@ -163,7 +163,7 @@ export default class DocumentReference {
|
|||
.documentSet(this.path, nativeData, writeOptions);
|
||||
}
|
||||
|
||||
update(...args: Array<any>): Promise<void> {
|
||||
update(...args: any[]): Promise<void> {
|
||||
let data = {};
|
||||
if (args.length === 1) {
|
||||
if (!isObject(args[0])) {
|
||||
|
|
|
@ -45,12 +45,13 @@ type QueryOptions = {
|
|||
startAfter?: any[],
|
||||
startAt?: any[],
|
||||
}
|
||||
type QueryListenOptions = {
|
||||
|
||||
export type QueryListenOptions = {
|
||||
includeDocumentMetadataChanges: boolean,
|
||||
includeQueryMetadataChanges: boolean,
|
||||
}
|
||||
|
||||
type Observer = {
|
||||
export type Observer = {
|
||||
next: (DocumentSnapshot) => void,
|
||||
error?: (Object) => void,
|
||||
}
|
||||
|
@ -81,7 +82,7 @@ export default class Query {
|
|||
this._referencePath = path;
|
||||
}
|
||||
|
||||
get firestore(): Object {
|
||||
get firestore(): Firestore {
|
||||
return this._firestore;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue