-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
31 lines (23 loc) · 889 Bytes
/
test.js
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
import { initializeApp, cert } from 'firebase-admin/app';
import { getFirestore } from 'firebase-admin/firestore';
import serviceAccount from './firebase-key.json' assert { type: 'json' };
import { assert } from 'console';
initializeApp({
credential: cert(serviceAccount),
});
const db = getFirestore();
const col = db.collection('leetcode_actions');
const uniqueValuesSet = new Set();
(async () => {
const collectionSnapshot = await col.get();
collectionSnapshot.forEach((doc) => {
// Access the field value and add it to the Set
const fieldValue = doc.data()['problemNumber'];
if (fieldValue == undefined) {
console.log(doc.id);
}
uniqueValuesSet.add(fieldValue);
});
// Now uniqueValuesArray contains all unique values for the specified field
console.log('Unique Values:', uniqueValuesSet.size);
})();