Skip to content

Copy and paste

  • MongoDB

You can copy documents from a collection tab and paste them into any collection, and copy a whole collection in the explorer and paste it into another database, on the same connection or another. Copied documents also go to the system clipboard as mongosh text, and a copied collection as its name.

  1. In a collection tab, right-click a document and choose Copy Document, or Copy All Documents for every document loaded in the tab.
  2. Open the target collection’s Paste Documents…: in its collection tab’s right-click menu, or in its menu in the explorer.
  3. The dialog shows the copied documents as mongosh text. Edit them if you need to, or paste text from elsewhere over them: one document or an array of them, in mongosh syntax or Extended JSON.
  4. Tick Give each document a new _id to let the server give each document its own _id. It is ticked to start with when you paste back into the collection the documents came from.
  5. Choose Paste, or Paste n documents.

The documents are inserted in order. A document refused by the server, such as one whose _id is taken, stops the paste there. On a production or confirm-writes connection the paste asks first and shows the insertMany command; a read-only connection does not offer it.

The page cannot read the system clipboard, so text copied in another program goes into the dialog’s editor with the usual paste keys. Copy as Extended JSON in the right-click menu copies a document as relaxed Extended JSON to the system clipboard only.

  1. Choose Copy Collection from a collection’s menu in the explorer.
  2. Open the menu of the target database, or its Collections folder, on any MongoDB connection, and choose Paste Collection followed by the collection’s name.
  3. Check the confirmation and choose Paste.
  • Into another database, on the same connection or another, the paste runs as a transfer job: a new collection of the same name gets the documents, with every BSON type, then the indexes. A collection of that name in the target database stops the copy. Follow the job in the jobs panel.
  • Into the collection’s own database, the paste opens Duplicate Collection…, which asks for a new name. See Rename, duplicate and clear a collection.

For more control over a copy between connections, such as appending to a collection that exists, use data transfer, which copies MongoDB collections to MongoDB too.

Documents Querybara 0.1.19 · built from89dc752