Keep these three functions in some file with utility functions and use them whenever you need to copy, delete, or move a document. 'Data was not copied properly to the target collection, please try again.', then( ( doc) => doc.exists & doc.data())Ĭonsole.error( 'Error reading document', ` $`) copy the document const docData = await docRef document reference const docRef = admin.firestore().collection(collectionFrom).doc(docId) Like user id and the time, the copy was made. And addData parameter is for any key-values that should be added to the resulting document. If playback doesnt begin shortly, try restarting your device. Just a single one or with all sub-collections possible is specified with the recursive param. How to Create Community and Collection in DSpace. Here is an example of how to copy a document. And unless you have a list with all possible sub-collections for every document, so you can iterate over it and copy the internals, you'll need a cloud function that can go through all sub-collections. But the documents can have sub-collections with more docs in it. That is something doable even with the client library. Reading a document's content and creating a new one in another collection with it. In this post, you'll find working functions to use with some explanations. To move a Firestore document from one collection to another, including all existing sub-collections, we will need a Cloud function that copies all documents and then delete existing ones.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |