Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-1698

cloneCollection always preserves db name in the destination DB

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • Server_Docs_20231030
    • None
    • manual
    • None

    Description

      The documentation for cloneCollection documents that it "creates a collection on the current database with the same name as the origin collection.": http://docs.mongodb.org/manual/reference/command/cloneCollection/

      However, testing and source inspection reveal that it always copies to the database of the same name as the source database, e.g.:

      [nelhage@anarchique:/tmp/mongo]$ mongo --port 9001
      MongoDB shell version: 2.4.3
      connecting to: 127.0.0.1:9001/test
      > use testdb
      switched to db testdb
      > db.runCommand({cloneCollection: "nelhage.mydb", from: "localhost:9000"})
      { "ok" : 1 }
      > db.mydb.find()
      > db.getSiblingDB('nelhage').mydb.find()
      { "_id" : ObjectId("51df57ffacab3e1ad799d62e"), "i" : 6 }

      Attachments

        Activity

          People

            sam.kleinman Sam Kleinman (Inactive)
            nelhage Nelson Elhage
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              10 years, 31 weeks, 2 days ago