How to move a firestore document from cloud functions?

前端 未结 2 516
南方客
南方客 2020-12-07 03:43

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.

Ca

相关标签:
2条回答
  • 2020-12-07 04:18

    Firebase Firestore do not support moving data; Its better to copy to new and delete existing.

    If your data is kind of transaction data;

    make sure execute operations in transaction block (delete only when copy is success)

    Also you can ensure using [ .validate() ] delete only if its exist in copied node

    0 讨论(0)
  • 2020-12-07 04:39

    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.

    0 讨论(0)
提交回复
热议问题