mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-23 03:59:18 +08:00
[firestore] Correctly support dates, GeoPoints and other types in where clause
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
import DocumentSnapshot from './DocumentSnapshot';
|
||||
import Path from './Path';
|
||||
import QuerySnapshot from './QuerySnapshot';
|
||||
import { buildTypeMap } from './utils/serialize';
|
||||
import { firestoreAutoId, isFunction, isObject } from '../../utils';
|
||||
|
||||
const DIRECTIONS = {
|
||||
@@ -261,10 +262,11 @@ export default class Query {
|
||||
// TODO: Validation
|
||||
// validate.isFieldPath('fieldPath', fieldPath);
|
||||
// validate.isFieldFilter('fieldFilter', opStr, value);
|
||||
const nativeValue = buildTypeMap(value);
|
||||
const newFilter = {
|
||||
fieldPath,
|
||||
operator: OPERATORS[opStr],
|
||||
value,
|
||||
value: nativeValue,
|
||||
};
|
||||
const combinedFilters = this._fieldFilters.concat(newFilter);
|
||||
return new Query(this.firestore, this._referencePath, combinedFilters,
|
||||
|
||||
@@ -37,7 +37,7 @@ const buildNativeArray = (array: Object[]): any[] => {
|
||||
return nativeArray;
|
||||
};
|
||||
|
||||
const buildTypeMap = (value: any): any => {
|
||||
export const buildTypeMap = (value: any): any => {
|
||||
const typeMap = {};
|
||||
const type = typeOf(value);
|
||||
if (value === null || value === undefined) {
|
||||
|
||||
Reference in New Issue
Block a user