Created
May 20, 2022 07:41
-
-
Save LCHCAPITALHUMAIN/56b7db5280df53f814edfd3293f7af37 to your computer and use it in GitHub Desktop.
react-admin perform query search upon firebase database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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