Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IN and ARRAY_CONTAINS_ANY queries #20

Merged
merged 1 commit into from Nov 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 25 additions & 5 deletions firestore/test.firestore.js
Expand Up @@ -797,27 +797,47 @@ describe("firestore", () => {
// [END array_contains_filter]
});

it("should handle an array contains any where", () => {
const citiesRef = db.collection('cities');
// [START array_contains_any_filter]
citiesRef.where('regions', 'array-contains-any',
['west_coast', 'east_coast']);
// [END array_contains_any_filter]
});

it("should handle an in where", () => {
const citiesRef = db.collection('cities');
// [START in_filter]
citiesRef.where('region', 'in', ['USA', 'Japan']);
// [END in_filter]

// [START in_filter_with_array]
citiesRef.where('region', 'in',
[['west_coast', 'east_coast']]);
// [END in_filter_with_array]
});

it("should handle compound queries", () => {
var citiesRef = db.collection("cities");
// [START chain_filters]
citiesRef.where("state", "==", "CO").where("name", "==", "Denver")
citiesRef.where("state", "==", "CA").where("population", "<", 1000000)
citiesRef.where("state", "==", "CO").where("name", "==", "Denver");
citiesRef.where("state", "==", "CA").where("population", "<", 1000000);
// [END chain_filters]
});

it("should handle range filters on one field", () => {
var citiesRef = db.collection("cities");
// [START valid_range_filters]
citiesRef.where("state", ">=", "CA").where("state", "<=", "IN")
citiesRef.where("state", "==", "CA").where("population", ">", 1000000)
citiesRef.where("state", ">=", "CA").where("state", "<=", "IN");
citiesRef.where("state", "==", "CA").where("population", ">", 1000000);
// [END valid_range_filters]
});

it("should not handle range filters on multiple field", () => {
var citiesRef = db.collection("cities");
expect(() => {
// [START invalid_range_filters]
citiesRef.where("state", ">=", "CA").where("population", ">", 100000)
citiesRef.where("state", ">=", "CA").where("population", ">", 100000);
// [END invalid_range_filters]
}).to.throwException();
});
Expand Down