【发布时间】:2019-09-17 19:22:45
【问题描述】:
我正在尝试在 Firebase 自动生成密钥时更新特定数据。
我尝试了下面的代码。它仍然不起作用:(
我试过了:
function updateHomeworkStatus(agent) {
var chosenHw = request.body.queryResult.outputContexts[0].parameters.chosenHw;
var status = request.body.queryResult.outputContexts[0].parameters.status;
var query = admin.database().ref('Homework').orderByChild('Name').equalTo(chosenHw);
query.once('value')
.then(snapshot => {
// Once we have a result, we can use the reference to it
var snapshotRef = snapshot.ref;
// We want to change the value of Completed field,
// so we get a reference to that
var completedRef = snapshotRef.child('CompletionStatus');
// We can then set it, since we have a direct reference to the
// field and there is nothing else that will be changed.
completedRef.update(status);
});
agent.add("Status has been changed to " + status);
}
例如(我附上了我的火力基地的图片):
Dialogflow:您要更改的作业的名称是什么 完成状态? (我已经这样做了)
当用户说“编码工作表 7”并且所需状态为“是”时, 具体数据会发生变化。 (这个编码部分我需要 hep)。
所以预期的结果将是“编码工作表 7”的 CompletionStatus 将更改为“否”。
【问题讨论】:
标签: javascript node.js firebase firebase-realtime-database dialogflow-es