function myFunction(){
var firebaseUrl = "https://example-app.firebaseio.com/";
var secret = "secret-key";
var base = FirebaseApp.getDatabaseByUrl(firebaseUrl, secret);
base.setData("test", "Hello Firebase");
}
function getAllData() {
var firebaseUrl = "https://example-app.firebaseio.com/";
var secret = "secret-key";
var base = FirebaseApp.getDatabaseByUrl(firebaseUrl, secret);
var data = base.getData();
for(var i in data) {
Logger.log(data[i].firstName + ' ' + data[i].lastName);
}
}
The data read is displayed in the Logs. To check logs click on click on View → Logs or simply use Control + Enter.
function getContact() {
var firebaseUrl = "https://example-app.firebaseio.com/";
var secret = "secret-key";
var base = FirebaseApp.getDatabaseByUrl(firebaseUrl, secret);
var contact = base.getData("Yash-Udasi");
Logger.log(contact);
}
The data read is displayed in the Logs. To check logs click on click on View → Logs or simply use Control + Enter.
function updateData() {
var firebaseUrl = "https://example-app.firebaseio.com/";
var secret = "secret-key";
var base = FirebaseApp.getDatabaseByUrl(firebaseUrl, secret);
base.updateData("Yash-Udasi/emailAddress", "[email protected]");
}