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