forked from firebase/snippets-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.solution-aggregation.js
43 lines (35 loc) · 1.28 KB
/
test.solution-aggregation.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
32
33
34
35
36
37
38
39
40
41
42
43
// [SNIPPET_REGISTRY disabled]
// [SNIPPETS_SEPARATION enabled]
// [START sample_doc]
const arinellDoc = {
name: 'Arinell Pizza',
avgRating: 4.65,
numRatings: 683
};
// [END sample_doc]
describe("firestore-solution-arrays", () => {
const { Firestore } = require("firebase/firestore");
/** @type {Firestore} */
let db;
before(async () => {
const { initializeApp } = require("firebase/app");
const { getFirestore, collection, doc, setDoc } = require("firebase/firestore");
const config = {
apiKey: "AIzaSyArvVh6VSdXicubcvIyuB-GZs8ua0m0DTI",
authDomain: "firestorequickstarts.firebaseapp.com",
projectId: "firestorequickstarts",
};
const app = initializeApp(config, "solution-arrays");
db = getFirestore(app);
await setDoc(doc(db, "restaurants", "arinell-pizza"), arinellDoc);
});
describe("solution-arrays", () => {
it("should get a collection of ratings", async () => {
// [START get_collection_ratings]
const { collection, getDocs } = require("firebase/firestore");
const ratingsRef = collection(db, "restaurants", "arinell-pizza", "ratings");
const ratingsDocs = await getDocs(ratingsRef);
// [END get_collection_ratings]
});
});
});