发布于 2015-09-14 14:56:15 | 280 次阅读 | 评论: 0 | 来源: 网络整理
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.
参数: |
|
---|
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.