将Firebase Firestore和Firebase Storage联合起来组合成一批?(Couple Firebase Firestore and Firebase Storage calls

系统教程 行业动态 更新时间:2024-06-14 17:03:52
将Firebase Firestore和Firebase Storage联合起来组合成一批?(Couple Firebase Firestore and Firebase Storage calls together into a batch?)

我正在寻找Firebase存储和Firebase Firestore的组合/批量调用的最佳实践。 例如:我需要从我的Firestore中删除与Firebase存储中的图像相关的文档。 是否有可能以这样的方式执行此操作:当其中一个操作失败时,整个事务将被还原?

I'm looking for a best practice on combined/batch calls for Firebase Storage and Firebase Firestore. For example: I need to delete a document from my Firestore which is related to an image in Firebase Storage. Is there a possibility to do this in such a way that when one of the actions fails, the whole transaction is being reverted?

最满意答案

没有真正的atomic/transactional方式,但是您可以使用云功能来可靠地实现它。

您可以删除文档,并使用onDelete触发器删除存储中的实际文件。

因此,当您无法删除文档时,文件不会发生任何事情。 如果您成功删除文档,则会触发云端功能以删除图像。

There is no real atomic/transactional way of doing that however you can use cloud functions to achieve it reliably.

You can delete a document, and use onDelete trigger to delete the actual file in the storage.

So when you can't delete the document, nothing will happen to the file. If you succeed to delete the document, cloud function will be triggered to delete the image.

更多推荐

本文发布于:2023-04-24 12:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/ab1eb18e51d6137d8920b22d4fb1f234.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:组合   Storage   Firestore   Firebase   calls

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!