Skip to content

Instantly share code, notes, and snippets.

@LCHCAPITALHUMAIN
Created May 20, 2022 07:41
Show Gist options
  • Save LCHCAPITALHUMAIN/56b7db5280df53f814edfd3293f7af37 to your computer and use it in GitHub Desktop.
Save LCHCAPITALHUMAIN/56b7db5280df53f814edfd3293f7af37 to your computer and use it in GitHub Desktop.
react-admin perform query search upon firebase database
test("FirebaseClient with filter gte", async () => {
const testDocs = [
{
title: "A",
obj: {volume: 100},
},
{
title: "B",
obj: {volume: 101},
},
{
title: "C",
obj: {volume: 99},
}
];
const collName = "list-filtered";
const collection = fire.db().collection(collName);
await Promise.all(testDocs.map((doc) => collection.add(doc)));
const client = new FirebaseClient(fire, {});
const result = await client.apiGetList(collName, {
filter: {
collectionQuery: (c: firebase.firestore.CollectionReference) => c.where('obj.volume', '>=', 100)
},
pagination: {
page: 1,
perPage: 10,
},
sort: {
field: "obj.volume",
order: "ASC",
},
});
const third = result.data.length as any;
expect(third).toBe(2);
}, 100000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment