Skip to content

Commit 9ef3fa3

Browse files
authored
IN and ARRAY_CONTAINS_ANY queries (firebase#20)
2 parents 690e78f + 0888838 commit 9ef3fa3

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

firestore/test.firestore.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -797,27 +797,47 @@ describe("firestore", () => {
797797
// [END array_contains_filter]
798798
});
799799

800+
it("should handle an array contains any where", () => {
801+
const citiesRef = db.collection('cities');
802+
// [START array_contains_any_filter]
803+
citiesRef.where('regions', 'array-contains-any',
804+
['west_coast', 'east_coast']);
805+
// [END array_contains_any_filter]
806+
});
807+
808+
it("should handle an in where", () => {
809+
const citiesRef = db.collection('cities');
810+
// [START in_filter]
811+
citiesRef.where('region', 'in', ['USA', 'Japan']);
812+
// [END in_filter]
813+
814+
// [START in_filter_with_array]
815+
citiesRef.where('region', 'in',
816+
[['west_coast', 'east_coast']]);
817+
// [END in_filter_with_array]
818+
});
819+
800820
it("should handle compound queries", () => {
801821
var citiesRef = db.collection("cities");
802822
// [START chain_filters]
803-
citiesRef.where("state", "==", "CO").where("name", "==", "Denver")
804-
citiesRef.where("state", "==", "CA").where("population", "<", 1000000)
823+
citiesRef.where("state", "==", "CO").where("name", "==", "Denver");
824+
citiesRef.where("state", "==", "CA").where("population", "<", 1000000);
805825
// [END chain_filters]
806826
});
807827

808828
it("should handle range filters on one field", () => {
809829
var citiesRef = db.collection("cities");
810830
// [START valid_range_filters]
811-
citiesRef.where("state", ">=", "CA").where("state", "<=", "IN")
812-
citiesRef.where("state", "==", "CA").where("population", ">", 1000000)
831+
citiesRef.where("state", ">=", "CA").where("state", "<=", "IN");
832+
citiesRef.where("state", "==", "CA").where("population", ">", 1000000);
813833
// [END valid_range_filters]
814834
});
815835

816836
it("should not handle range filters on multiple field", () => {
817837
var citiesRef = db.collection("cities");
818838
expect(() => {
819839
// [START invalid_range_filters]
820-
citiesRef.where("state", ">=", "CA").where("population", ">", 100000)
840+
citiesRef.where("state", ">=", "CA").where("population", ">", 100000);
821841
// [END invalid_range_filters]
822842
}).to.throwException();
823843
});

0 commit comments

Comments
 (0)