如何从云功能移出Firestore文档? [英] How to move a firestore document from cloud functions?

查看:62
本文介绍了如何从云功能移出Firestore文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个云功能,可以监听集合中的文档更新.如果某个特殊字段已更新,我想将此文档移至另一个集合.

I have a cloud function which listens for document updates within a collection. If a special field is updated, I want to move this document to another collection.

我可以简单地更新文档的位置吗?

Can I simply update the location of the document?

还是我必须编写包含文档的get(),write()和delete()的事务,还是有更好的解决方案?

Or do I have to write a transaction which contains a get(), write() and delete() of the document, or is there a better solution?

这似乎是一个常见的用例,但是我找不到任何文档.

That seems to be a common use case but I cant find any documentation.

推荐答案

Firestore当前不提供移动"操作.您必须按照问题中的建议进行操作:在交易中自行复制文档.

Firestore currently doesn't offer a "move" operation. You'll have to do what you proposed in your question: copy the document yourself in a transaction.

这篇关于如何从云功能移出Firestore文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆