发布于 2015-09-14 14:56:15 | 280 次阅读 | 评论: 0 | 来源: 网络整理

cloneCollection

The cloneCollection command copies a collection from a remote server to the server where you run the command. cloneCollection does not allow you to clone a collection through a mongos: you must connect directly to the mongod instance.

参数:
  • from – Specify a resolvable hostname, and optional port number of the remote server where the specified collection resides.
  • query – Optional. A query document, in the form of a document, that filters the documents in the remote collection that cloneCollection will copy to the current database. See db.collection.find().
  • copyIndexes (Boolean) – Optional. true by default. When set to false the indexes on the originating server are not copied with the documents in the collection.

Consider the following example:

{ cloneCollection: "users.profiles", from: "mongodb.example.net:27017", query: { active: true }, copyIndexes: false }

This operation copies the profiles collection from the users database on the server at mongodb.example.net. The operation only copies documents that satisfy the query { active: true } and does not copy indexes. cloneCollection copies indexes by default, but you can disable this behavior by setting { copyIndexes: false }. The query and copyIndexes arguments are optional.

cloneCollection creates a collection on the current database with the same name as the origin collection. If, in the above example, the profiles collection already exists in the local database, then MongoDB appends documents in the remote collection to the destination collection.

最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务