-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrian.json
More file actions
43 lines (36 loc) · 2.1 KB
/
brian.json
File metadata and controls
43 lines (36 loc) · 2.1 KB
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
/users/useruid/ name: ..
email: ..
lists/2343 /name: eggs
category: fridge
details: ..
/3143/ name: flour
category: pantry
details: ..
function writeFoodIntoList(){
var details="lasts a long time";
var name="peanut butter";
firebase.auth().onAuthStateChanged(function(user){
db.collection("users")
.doc(user.uid)
.collection("lists")
.add({
"name": name,
"details": details,
"category": "fridge"
})
})
}
function readFromList(category){
firebase.auth().onAuthStateChanged(function(user){
db.collection("users")
.doc(user.uid)
.collection("lists")
.where("category", "==", "fridge")
.get() //get whole list
.then(function(snap){
snap.forEach(function(doc){ //cycle thru items in list
console.log(doc.data().name);
})
})
})
}