[firestore] Correctly support dates, GeoPoints and other types in where clause

This commit is contained in:
Chris Bianca
2017-10-31 15:32:08 +00:00
parent d8fd09adef
commit 6ae0049338
8 changed files with 247 additions and 21 deletions

View File

@@ -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,

View File

@@ -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) {