0

enter image description here

What I want to do is move pushToken from a particular document to a collection within the same document. Can someone please tell me if it's possible. And if yes, please tell how it could be.

Shubham Bisht
  • 577
  • 2
  • 26
  • 51

1 Answers1

1

What I want to do is move pushToken from a particular document to a collection within the same document.

You cannot move only a single property. Since you say it's the same document, you can copy the enitre document from a location to another. Cloud Firestore listeners fire on the document level. There is no way to get triggered with just particular fields in a document.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
  • So, what I should be doing is copy the entire document to another collection within same document. And from the copied document, delete all fields except pushToken? Will that be the right approach for the solution? – Shubham Bisht Apr 17 '19 at 09:53
  • Yes, it will be the right approach but only if you know exactly that you will not need the values of the other properties, otherwise you can copy the entire document. – Alex Mamo Apr 17 '19 at 10:02
  • Thank you. Could please tell me how do I copy the entire document and paste it in the same document? Any link you if you could provide. – Shubham Bisht Apr 17 '19 at 10:07
  • 1
    You can check [this](https://stackoverflow.com/questions/47244403/how-to-move-a-document-in-cloud-firestore) out. It's for Android but same rules apply to react native. – Alex Mamo Apr 17 '19 at 10:12
  • If you are not figuring out, please show us where you are stuck and please post another fresh question using a [MCVE](https://stackoverflow.com/help/mcve), so me and other Firebase developers can help you. – Alex Mamo Apr 18 '19 at 06:39
  • @ShubhamBisht I will and if I'll know the answer I'll write it to you. – Alex Mamo Apr 25 '19 at 09:46