I want to clone a collection to a new collection, remove all the documents, and then import new documents from a csv file. When I do the copy using copyTo everything works fine. The datatypes are copied over from the source collection to the new collection. However, after I remove all the documents from the new collection and import from the csv, the datatypes are lost. The datatypes from my source csv are already setup to match what is in the source collection I copied from.
A new collection doesn't have a fixed schema so documents added don't have to be similar unless you've created the collection using the validator
option. You can also add validation to an existing collection. See Document Validation in the MongoDB manual.