简体   繁体   English

使用Cloud Functions添加子级?

[英]Add child using Cloud Functions?

How do I add a child after .onWrite using Cloud Functions? 如何使用Cloud Functions在.onWrite之后添加子.onWrite

在此处输入图片说明

Code skeleton: 代码框架:

exports.addNewValue = functions.database.ref('/messages/{pushId}')
.onWrite(event => {
// add child newValue: "randomValue" to the newly added key above

If you want to update the database at the same location where the change occurred with some key/value pair: 如果要使用某些键/值对在发生更改的位置更新数据库:

event.data.adminRef.update({key:"value"})

I suggest also getting acquainted with the documentation for how to work with database triggers , and how to write to Realtime Database using the JavaScript API. 我建议还熟悉如何使用数据库触发器以及如何使用JavaScript API 写入Realtime Database的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM