Las funciones de Firebase se suman a la base de datos
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);
});
Disgusted Dugong