How to move a firestore document from cloud functions?

前端 未结 2 526
南方客
南方客 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

提交回复
热议问题