Reputation: 348
I want to perform several operations on my existing data of Database-A
and Collection-1
. Once I perform all the operations I will lose my original data, as the data will get replaced by new data.
I want to create copy of my entire data in a different collection Collection-B
into the same database Database-A
or a different database Test
, so that at a later stage I will not lose my existing data.
Any Suggestions?
Upvotes: 1
Views: 183
Reputation: 3732
Documents are uniquely identified by the Database and URI.
Collections do not copy documents.
If you want to preserve stages of processing, it is more efficient and less error prone to write the new data to a different URI or Database ( URI is easier ), rather than copy the old data and then write new data ( 1 doc write vs 2, no copies needed and safer as no documents get overwritten ).
Either approach, using a URI "sub directory" hierarchy is a simple and common approach.
e.g.
This is flexible over many stages.
If you use separate databases there is better isolation, but requires you to configure a new database for each stage, and manage permissions, indexes, etc.
The online docs gave good examples on how to copy documents if you decide to copy instead of writing to a new database.
Upvotes: 3