Answers for "add to firebase database"

2

add to firebase database

db.collection("cities").add({
    name: "Tokyo",
    country: "Japan"
})
.then(function(docRef) {
    console.log("Document written with ID: ", docRef.id);
})
.catch(function(error) {
    console.error("Error adding document: ", error);
});
Posted by: Guest on July-21-2020
1

javascript write to firebase

function writeUserData(userId, name, email, imageUrl) {
  firebase.database().ref('users/' + userId).set({
    username: name,
    email: email,
    profile_picture : imageUrl
  });
}
Posted by: Guest on August-25-2020
0

firebase functions add to database

import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp(functions.config().firebase);

exports.onMsgAdded = functions.database.ref('/users/{uid}/messages/{to_uid}/{msg}').onCreate((snap, context) =>{
    const data = snap.val();
    const msgRoot = admin.database().ref('/users/' + context.params.to_uid + '/messages/' + context.params.uid);
    return msgRoot.set(data);
});
Posted by: Guest on July-03-2020

Code answers related to "add to firebase database"

Browse Popular Code Answers by Language