Skip to content

Commit

Permalink
fix(fireforce): use serializeItems
Browse files Browse the repository at this point in the history
  • Loading branch information
triniwiz committed Oct 25, 2021
1 parent bdacb06 commit c54376a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 37 deletions.
56 changes: 20 additions & 36 deletions packages/firebase-firestore/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,106 +548,90 @@ export class Query<T extends DocumentData = DocumentData> implements IQuery<T> {
if (fieldPath instanceof FieldPath) {
switch (opStr) {
case '!=':
query = this.native.queryWhereFieldPathIsNotEqualTo(fieldPath.native, value?.native || value);
query = this.native.queryWhereFieldPathIsNotEqualTo(fieldPath.native, serializeItems(value));
break;
case '<':
query = this.native.queryWhereFieldPathIsLessThan(fieldPath.native, value?.native || value);
query = this.native.queryWhereFieldPathIsLessThan(fieldPath.native, serializeItems(value));
break;
case '>':
query = this.native.queryWhereFieldPathIsGreaterThan(fieldPath.native, value?.native || value);
query = this.native.queryWhereFieldPathIsGreaterThan(fieldPath.native, serializeItems(value));
break;
case '<=':
query = this.native.queryWhereFieldPathIsLessThanOrEqualTo(fieldPath.native, value?.native || value);
query = this.native.queryWhereFieldPathIsLessThanOrEqualTo(fieldPath.native, serializeItems(value));
break;
case '>=':
query = this.native.queryWhereFieldPathIsGreaterThanOrEqualTo(fieldPath.native, value?.native || value);
query = this.native.queryWhereFieldPathIsGreaterThanOrEqualTo(fieldPath.native, serializeItems(value));
break;
case '==':
query = this.native.queryWhereFieldPathIsEqualTo(fieldPath.native, value?.native || value);
query = this.native.queryWhereFieldPathIsEqualTo(fieldPath.native, serializeItems(value));
break;
case 'array-contains':
query = this.native.queryWhereFieldPathArrayContains(
fieldPath.native,
Array.isArray(value) ? value.map((val) => {
return val?.native || val;
}) : value
serializeItems(value)
);
break;
case 'array-contains-any':
query = this.native.queryWhereFieldPathArrayContainsAny(
fieldPath.native,
value.map((val) => {
return val?.native || val;
})
serializeItems(value)
);
break;
case 'in':
query = this.native.queryWhereFieldPathIn(
fieldPath.native,
value.map((val) => {
return val?.native || val;
})
serializeItems(value)
);
break;
case 'not-in':
query = this.native.queryWhereFieldPathNotIn(
fieldPath.native,
value.map((val) => {
return val?.native || val;
})
serializeItems(value)
);
break;
}
} else {
switch (opStr) {
case '!=':
query = this.native.queryWhereFieldIsNotEqualTo(fieldPath as any, value?.native || value);
query = this.native.queryWhereFieldIsNotEqualTo(fieldPath as any, serializeItems(value));
break;
case '<':
query = this.native.queryWhereFieldIsLessThan(fieldPath as any, value?.native || value);
query = this.native.queryWhereFieldIsLessThan(fieldPath as any, serializeItems(value));
break;
case '>':
query = this.native.queryWhereFieldIsGreaterThan(fieldPath as any, value?.native || value);
query = this.native.queryWhereFieldIsGreaterThan(fieldPath as any, serializeItems(value));
break;
case '<=':
query = this.native.queryWhereFieldIsLessThanOrEqualTo(fieldPath as any, value?.native || value);
query = this.native.queryWhereFieldIsLessThanOrEqualTo(fieldPath as any, serializeItems(value));
break;
case '>=':
query = this.native.queryWhereFieldIsGreaterThanOrEqualTo(fieldPath as any, value?.native || value);
query = this.native.queryWhereFieldIsGreaterThanOrEqualTo(fieldPath as any, serializeItems(value));
break;
case '==':
query = this.native.queryWhereFieldIsEqualTo(fieldPath as any, value?.native || value);
query = this.native.queryWhereFieldIsEqualTo(fieldPath as any, serializeItems(value));
break;
case 'array-contains':
query = this.native.queryWhereFieldArrayContains(
fieldPath as any,
value.map((val) => {
return val?.native || val;
})
serializeItems(value)
);
break;
case 'array-contains-any':
query = this.native.queryWhereFieldArrayContainsAny(
fieldPath as any,
Array.isArray(value) ? value.map((val) => {
return val?.native || val;
}) : value
serializeItems(value)
);
break;
case 'in':
query = this.native.queryWhereFieldIn(
fieldPath as any,
value.map((val) => {
return val?.native || val;
})
serializeItems(value)
);
break;
case 'not-in':
query = this.native.queryWhereFieldNotIn(
fieldPath as any,
value.map((val) => {
return val?.native || val;
})
serializeItems(value)
);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase-firestore/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/firebase-firestore",
"version": "1.0.0-alpha.15",
"version": "1.0.0-alpha.16",
"description": "NativeScript Firebase - Firestore",
"main": "index",
"typings": "index.d.ts",
Expand Down

0 comments on commit c54376a

Please sign in to comment.