Funções de Firebase Adicionar ao banco de dados

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