Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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);
});
Comment

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);
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: destructuring an object js 
Javascript :: array includes javascript 
Javascript :: jest mock mockname 
Javascript :: function for flatten an array 
Javascript :: isotope js 
Javascript :: get data from google sheets javascript 
Javascript :: swr npm 
Javascript :: simple node rest 
Javascript :: then and catch in promise 
Javascript :: random trong js 
Javascript :: doughnut chartjs with react display percentage 
Javascript :: multi dimensional array javascript 
Javascript :: remove duplicate values from array 
Javascript :: setup react app from cpanel 
Javascript :: javascript merge two array with spread operator 
Javascript :: parsing json object in java 
Javascript :: enable swipe using javascript 
Javascript :: mongoose select 
Javascript :: nuxt import css 
Javascript :: how to add onclick to child element created javascript 
Javascript :: delete last array element javascript 
Javascript :: export aab bundle react native android 
Javascript :: UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON 
Javascript :: how to pass sequelize transaction to save method 
Javascript :: remove from string javascript regex 
Javascript :: brython.js download 
Javascript :: react merge two objects 
Javascript :: is dark mode 
Javascript :: infinite scroll for chat react js 
Javascript :: highlight nav menu on scroll with javascript 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =