I want to clone an existing collection, including data and indexes, to a new collection with another name within the same database, using mongodb JSON interface (not the command-line interface).
I've tried:
cloneCollection
- didn't work. is for cloning across databases.aggregate
with an$out
operator - that copies just the data but not the indexes.
The aggregate command I've tried:
{"aggregate":"orig_coll", "pipeline":[{"$out":"orig_clone"}]}