-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
33 lines (28 loc) · 1005 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import * as firebase from 'firebase';
import '@firebase/firestore';
firebase.initializeApp({
// NOTE: Replace the values below with those for your own Firebase project.
apiKey: "AIza...",
appId: "1:3577....",
projectId: "..."
});
async function getDepartmentAbsentCount() {
const snapshot = await firebase.firestore().collection('XXXX').where('XXX', '>', 0).get()
return snapshot.docs.map(doc => doc.data());
}
async function main() {
// Create some documents for the query.
const collection = firebase.firestore().collection('XXXX');
await collection.doc("Match1").set({"XXX": 1});
await collection.doc("Match2").set({"XXX": 2});
await collection.doc("NoMatch1").set({"XXX": 0});
await collection.doc("NoMatch2").set({"XXX": 1});
// Run the problematic query.
const xyzList = ["abc", "XYZ", "pqr"];
xyzList.forEach(async (item) => {
await getDepartmentAbsentCount().then((data: any) => {
console.log("Response =" + JSON.stringify(data));
})
})
}
main()