[DOCS-1657] db.collection.copyTo is not documented Created: 27/Jun/13  Updated: 30/Oct/23  Resolved: 22/Aug/13

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Task Priority: Minor - P4
Reporter: Jeremy Mikola Assignee: Zack Brown
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 10 years, 16 weeks, 1 day ago

 Description   

I believe this was introduced in 2.1, but I'm not certain.

> db.foo.copyTo
function ( newName ){
    return this.getDB().eval(
        function( collName , newName ){
            var from = db[collName];
            var to = db[newName];
            to.ensureIndex( { _id : 1 } );
            var count = 0;
 
            var cursor = from.find();
            while ( cursor.hasNext() ){
                var o = cursor.next();
                count++;
                to.save( o );
            }
 
            return count;
        } , this.getName() , newName
    );
}



 Comments   
Comment by auto [ 30/Oct/13 ]

Author:

{u'username': u'Zackrobat', u'name': u'Zack Brown', u'email': u'zack.brown@10gen.com'}

Message: DOCS-1657: db.collection.copyTo is not documented

Signed-off-by: Sam Kleinman <samk@10gen.com>
Branch: master
https://github.com/mongodb/docs/commit/271297795fa03205430c31a9c3b5dbdf41957262

Comment by auto [ 30/Oct/13 ]

Author:

{u'username': u'Zackrobat', u'name': u'Zack Brown', u'email': u'zack.brown@10gen.com'}

Message: DOCS-1657: db.collection.copyTo is not documented

Signed-off-by: Sam Kleinman <samk@10gen.com>
Branch: v2.4
https://github.com/mongodb/docs/commit/289628b12d0314d40fec0b4c53a1e735921f9b48

Comment by auto [ 30/Oct/13 ]

Author:

{u'username': u'Zackrobat', u'name': u'Zack Brown', u'email': u'zack.brown@10gen.com'}

Message: DOCS-1657: db.collection.copyTo is not documented

Signed-off-by: Sam Kleinman <samk@10gen.com>
Branch: v2.2
https://github.com/mongodb/docs/commit/b537d39b395f7fa6b5f9a6e11c986a325b3ec3d7

Comment by Jeremy Mikola [ 27/Jun/13 ]

Related FAQ entry: http://docs.mongodb.org/manual/faq/developers/#how-do-you-copy-all-objects-from-one-collection-to-another

Generated at Thu Feb 08 07:41:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.