/
test.js
55 lines (44 loc) · 1.77 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Import the functions you need from the SDKs you need
import 'babel-polyfill';
import { USERS, REVIEWS, LOCATIONS, GIVEAWAYS } from './constants.js'
import firebase from "firebase/compat/app";
import "firebase/compat/firestore";
// import { getFirestore, collection, doc, getDoc, getDocs, query } from "firebase/firestore";
// import firebase from "firebase/app";
// import "firebase/auth";
// import "firebase/firestore";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyBkfTS_GTzav5PeqXHymLkXer_HzSPFs60",
authDomain: "housing-buddy.firebaseapp.com",
projectId: "housing-buddy",
storageBucket: "housing-buddy.appspot.com",
messagingSenderId: "629222902668",
appId: "1:629222902668:web:37cc17a1c1ffcdb4e364a9",
measurementId: "G-1BCV6QWHH8"
};
// Initialize Firebase
const app = firebase.initializeApp(firebaseConfig);
const firestore = app.firestore();
// const app = initializeApp(firebaseConfig);
// const analytics = getAnalytics(app);
// const firestore = getFirestore(app);
async function getLocationReviews(locationID) {
console.log('executing');
const documentSnapshot = await firestore.collection(LOCATIONS).doc(locationID).get();
const reviewIDs = documentSnapshot.data().reviewIDs;
let reviewObjects = [];
reviewIDs.forEach(async (id) => {
reviewObjects.push(
await firestore.collection(REVIEWS).doc(id).get().then((value) => {
return value.data();
})
);
console.log(id);
});
return reviewObjects;
}
getLocationReviews('DJBUYlcSJIeTfvUkCMQO');