Die*_*o P 10 firebase firebase-realtime-database google-cloud-functions
函数执行没有错误.我正在获得这个地位
函数执行耗时60004毫秒,完成状态:'超时'
我不确定是什么问题.我功能中的一切对我来说都很好.我还注意到函数有时需要几秒钟来更新数据库,有时它会立即生效.执行时间从即刻到几秒不等,这是正常的吗?应该立即执行时间吗?
exports.countproposals = functions.database.ref("/proposals/{jobid}/{propid}").onWrite((event) => {
const jobid = event.params.jobid;
const userId = event.params.propid;
const userRef = admin.database().ref(`users/${userId}/proposals/sent`);
if (event.data.exists() && !event.data.previous.exists()) {
userRef.child(jobid).set({
timestamp: admin.database.ServerValue.TIMESTAMP
});
} else if (!event.data.exists() && event.data.previous.exists()) {
userRef.child(jobid).remove();
}
const collectionRef = admin.database().ref(`/jobs/${jobid}`);
const countRef = collectionRef.child("proposals");
return countRef.transaction(current => {
if (event.data.exists() && !event.data.previous.exists()) {
return (current || 0) + 1;
} else if (!event.data.exists() && event.data.previous.exists()) {
return (current || 0) - 1;
}
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2533 次 |
| 最近记录: |