OPTIONS
翻译或纠错本页面

db.cloneCollection()

说明

db.cloneCollection(from, collection, query)

直接在Mongodb实例间复制数据。 db.cloneCollection() 方法封装了 cloneCollection 命令,并接收如下参数:

Parameter Type Description
from string Host name of the MongoDB instance that holds the collection to copy.
collection string The collection in the MongoDB instance that you want to copy. db.cloneCollection() will only copy the collection with this name from database of the same name as the current database the remote MongoDB instance. If you want to copy a collection from a different database name you must use the cloneCollection directly.
query document Optional. A standard query document that limits the documents copied as part of the db.cloneCollection() operation. All query selectors available to the find() are available here.

db.cloneCollection() 不允许通过 mongos 复制数据。必须直接连接 mongod 实例。