一段时间后更新 Firebase Firestore 数据
我想在创建后的特定时间后更新我的 firestore 插入的字段。我搜索了几种可能性并提出了云功能。不幸的是,java 脚本对我来说并不容易理解以编写该函数。另外,我红色了,无论如何,在一段时间后不可能执行代码。
那么如何在不编写大量 js 代码并支付使用该函数费用的情况下解决这个问题呢?也许第二个应用程序只是一个周期性计时器,并一次又一次地检查日期时间字段。 (我可以 24/7 运行该应用程序)
谢谢大家
I want to update a field of my firestore insert after a specific amount of time after it was created. I searched for several possibilities and came up with cloud functions. Unfortunately, java script isn't as easy for me to understand in order to write that function. In addition I red, there isn't a possibility to execute code after a amount of time, anyway.
So how can I handle that problem without writing a lot of js code and paying for the use of that function. Maybe a second application which is just a periodic timer and checks the DateTime field again and again. (Would be possible for me to run that application 24/7)
Thanks guys
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建一个云函数,该函数在创建文档时触发。您可以使用像
setTimeout()
这样的计时器来执行更改文档的函数。看下面的示例代码:
这是我执行上面函数时的日志。
您可能需要检查 Cloud Firestore触发器 用于其他触发器和
setTimeout()< /code>
了解您可以在用例中使用的其他超时选项。
You can create a cloud function which triggers when a document is created. You can use timers like
setTimeout()
to execute a function which changes the document.Look at the sample code below:
Here's the logs when I executed the function above.
You may want to check Cloud Firestore triggers for other triggers and
setTimeout()
for other timeout options that you can use in your use-case.