mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-24 04:24:52 +08:00
[android] Add the first raft of Android support
This commit is contained in:
@@ -5,22 +5,23 @@
|
||||
import DocumentSnapshot from './DocumentSnapshot';
|
||||
import Path from './Path';
|
||||
import QuerySnapshot from './QuerySnapshot';
|
||||
import INTERNALS from './../../internals';
|
||||
|
||||
const DIRECTIONS = {
|
||||
DESC: 'descending',
|
||||
desc: 'descending',
|
||||
ASC: 'ascending',
|
||||
asc: 'ascending'
|
||||
ASC: 'ASCENDING',
|
||||
asc: 'ASCENDING',
|
||||
DESC: 'DESCENDING',
|
||||
desc: 'DESCENDING',
|
||||
};
|
||||
const DOCUMENT_NAME_FIELD = '__name__';
|
||||
|
||||
const OPERATORS = {
|
||||
'<': 'LESS_THAN',
|
||||
'<=': 'LESS_THAN_OR_EQUAL',
|
||||
'=': 'EQUAL',
|
||||
'==': 'EQUAL',
|
||||
'>': 'GREATER_THAN',
|
||||
'>=': 'GREATER_THAN_OR_EQUAL',
|
||||
'<': 'LESS_THAN',
|
||||
'<=': 'LESS_THAN_OR_EQUAL',
|
||||
};
|
||||
|
||||
export type Direction = 'DESC' | 'desc' | 'ASC' | 'asc';
|
||||
@@ -34,6 +35,8 @@ type FieldOrder = {
|
||||
fieldPath: string,
|
||||
}
|
||||
type QueryOptions = {
|
||||
endAt?: any[],
|
||||
endBefore?: any[],
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
selectFields?: string[],
|
||||
@@ -92,12 +95,12 @@ export default class Query {
|
||||
get(): Promise<QuerySnapshot> {
|
||||
return this._firestore._native
|
||||
.collectionGet(
|
||||
this._referencePath._parts,
|
||||
this._referencePath.relativeName,
|
||||
this._fieldFilters,
|
||||
this._fieldOrders,
|
||||
this._queryOptions,
|
||||
)
|
||||
.then(nativeData => new QuerySnapshot(nativeData));
|
||||
.then(nativeData => new QuerySnapshot(this._firestore, this, nativeData));
|
||||
}
|
||||
|
||||
limit(n: number): Query {
|
||||
@@ -116,12 +119,13 @@ export default class Query {
|
||||
// TODO: Validation
|
||||
// validate.isInteger('n', n);
|
||||
|
||||
const options = {
|
||||
/* const options = {
|
||||
...this._queryOptions,
|
||||
offset: n,
|
||||
};
|
||||
return new Query(this.firestore, this._referencePath, this._fieldFilters,
|
||||
this._fieldOrders, options);
|
||||
this._fieldOrders, options); */
|
||||
throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_CLASS_METHOD('Query', 'offset'));
|
||||
}
|
||||
|
||||
onSnapshot(onNext: () => any, onError?: () => any): () => void {
|
||||
@@ -129,9 +133,9 @@ export default class Query {
|
||||
}
|
||||
|
||||
orderBy(fieldPath: string, directionStr?: Direction = 'asc'): Query {
|
||||
//TODO: Validation
|
||||
//validate.isFieldPath('fieldPath', fieldPath);
|
||||
//validate.isOptionalFieldOrder('directionStr', directionStr);
|
||||
// TODO: Validation
|
||||
// validate.isFieldPath('fieldPath', fieldPath);
|
||||
// validate.isOptionalFieldOrder('directionStr', directionStr);
|
||||
|
||||
if (this._queryOptions.startAt || this._queryOptions.endAt) {
|
||||
throw new Error('Cannot specify an orderBy() constraint after calling ' +
|
||||
@@ -148,6 +152,7 @@ export default class Query {
|
||||
}
|
||||
|
||||
select(varArgs: string[]): Query {
|
||||
/*
|
||||
varArgs = Array.isArray(arguments[0]) ? arguments[0] : [].slice.call(arguments);
|
||||
const fieldReferences = [];
|
||||
|
||||
@@ -167,7 +172,8 @@ export default class Query {
|
||||
};
|
||||
|
||||
return new Query(this.firestore, this._referencePath, this._fieldFilters,
|
||||
this._fieldOrders, options);
|
||||
this._fieldOrders, options);*/
|
||||
throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_CLASS_METHOD('Query', 'select'));
|
||||
}
|
||||
|
||||
startAfter(fieldValues: any): Query {
|
||||
|
||||
Reference in New Issue
Block a user