简体   繁体   English

如何从云功能中止到Firebase实时数据库的创建?

[英]How to abort creation into firebase realtime database from a cloud function?

I'm creating an application that uses two step object creation into firebase realtime database. 我正在创建一个使用两步对象创建到Firebase实时数据库中的应用程序。

What I want is that on a cloud function that catches onCreate event, if some rules are not complete, then the create action be stopped. 我想要的是在捕获onCreate事件的云函数上,如果某些规则不完整,则将停止create操作。

Is there a way to do that? 有没有办法做到这一点? Or I need to remove the node instead of reject the creation? 还是我需要删除节点而不是拒绝创建?

Thank you! 谢谢!

There currently is no way to reschedule a trigger. 当前无法重新安排触发器的时间。 So indeed, you'll either have to create a new node or trigger a re-check in some other way, eg a regular cron trigger to clean up the previously unhandled nodes ( blog , video ). 因此,实际上,您要么必须创建一个新节点,要么以其他方式触发重新检查,例如,定期的cron触发器以清理以前未处理的节点( blogvideo )。

You might want to consider a command-response model for database writes. 您可能要考虑数据库写入的命令响应模型。 Instead of writing directly into the database and expecting that a function cancel the write, push a "command" object into the database that describes what you want to do, at a different location, and have a function respond to that command to determine what should actually be done. 与其直接写到数据库中并期望某个函数取消写操作,不如将一个“命令”对象推入数据库,该对象描述您要在其他位置执行的操作,并让一个函数响应该命令以确定应该执行的操作实际完成。 Your function can then determine whether or not to commit a final write if the conditions are OK. 然后,如果条件确定,您的函数可以确定是否提交最终写入。

I gave a talk at Google I/O 2017 that outlines this strategy with respect to a multi-player turn based game that intercepts all move requests to determine if they're valid before committing them to the game. 我在2017年Google I / O大会上的演讲中概述了基于多人回合游戏的这一策略,该游戏在将所有移动请求提交到游戏之前会拦截所有移动请求以确定它们是否有效。 The part about command-response starts here . 关于命令响应的部分从此处开始

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

相关问题 Firebase实时数据库中的云功能 - Cloud Function in Firebase Realtime Database 如何使用云功能将子级添加到Firebase实时数据库的列表中? - How to add child to a List in Firebase Realtime Database with a cloud function? 如何使用云 function 获取 Firebase 中的实时数据库? - How to get Realtime Database in Firebase by using cloud function? 如何使用 Javascript 云从 Firebase 实时数据库中随机获取子密钥名称 function - How to get a child key name randomly from the Firebase Realtime database with a Javascript cloud function 如何做云 function firebase 将数据从 Bucket 实时导入数据库 - how to do a cloud function firebase importing data from Bucket to database realtime 如何使用 Javascript 从云 Function 更新实时数据库? - How to update Realtime Database from Cloud Function using Javascript? 如果Firebase实时数据库中存在数据库节点,请使用云功能检查 - Checking with Cloud Function if a database node exists in Firebase Realtime Database 如何使用 firebase 云函数从 firebase-realtime-database 中获取数据? - How to fetch data from firebase-realtime-database using firebase cloud functions? Firebase 实时数据库中的云函数 - Cloud Functions in Firebase Realtime Database 使用 Firebase Cloud Function 增加新用户的实时数据库计数 - Increment Realtime Database count on new user with Firebase Cloud Function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM