-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain_firebase.js
More file actions
executable file
·43 lines (41 loc) · 1.38 KB
/
main_firebase.js
File metadata and controls
executable file
·43 lines (41 loc) · 1.38 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
var db = firebase.firestore();
function addNames() {
var firstName = document.getElementById("firstName_field").value;
var lastName = document.getElementById("lastName_field").value;
var email = document.getElementById("email_field").value;
var destination = "";
var suite = "";
var date = "";
var confirmationNum= "";
// Add a new document in collection "cities"
db.collection("users").doc().set({
firstName: firstName,
lastName: lastName,
email: email,
destination: destination,
suite: suite,
date: date,
confirmationNum: confirmationNum
})
.then(function () {
console.log("Document successfully written!");
})
.catch(function (error) {
console.error("Error writing document: ", error);
});
}
var user = firebase.auth().currentUser;
function addDestination() {
var destination = document.getElementById("destination").innerHTML;
// Add a new document in collection "cities"
db.collection(user.currentUser).doc(user.currentUser.document).update({
destination: destination
})
.then(function () {
console.log("Document successfully written!");
window.open('room.html', '_self');
})
.catch(function (error) {
console.error("Error writing document: ", error);
});
}