From c48212cc179bf80c1575fa3a4fea0f5049f2629c Mon Sep 17 00:00:00 2001 From: Fabian Stamm Date: Sat, 15 Aug 2020 20:33:18 +0200 Subject: [PATCH] Fix bug with where queries --- src/database/query.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/database/query.ts b/src/database/query.ts index ab4c1f8..b723b73 100644 --- a/src/database/query.ts +++ b/src/database/query.ts @@ -490,7 +490,7 @@ export class CollectionQuery extends Query { } } - private _where: IQueryWhereArray[] = []; + private _where: IQueryWhereArray[]; public set where(value: IQueryWhere[]) { const invalidWhere = new QueryError("Invalid Where"); if (!Array.isArray(value)) throw invalidWhere; @@ -573,6 +573,7 @@ export class CollectionQuery extends Query { while (parts.length > 0) { let seg = parts.shift(); + console.log(data, seg, data[seg]); d = data[seg]; if (d === undefined || d === null) break; // Undefined/Null has no other fields! } @@ -580,7 +581,7 @@ export class CollectionQuery extends Query { } private _fitsWhere(data: any): boolean { - if (this._where.length > 0) { + if (this._where && this._where.length > 0) { return this._where.every(([fieldPath, opStr, value]) => { let val = this._getFieldValue(data, fieldPath); switch (opStr) {