Skip to content

Instantly share code, notes, and snippets.

@hicay
Last active September 5, 2017 09:56
Show Gist options
  • Select an option

  • Save hicay/385ade8c61890cbffa7a69d42d5d7384 to your computer and use it in GitHub Desktop.

Select an option

Save hicay/385ade8c61890cbffa7a69d42d5d7384 to your computer and use it in GitHub Desktop.

Revisions

  1. hicay renamed this gist Sep 5, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. hicay created this gist Sep 5, 2017.
    9 changes: 9 additions & 0 deletions MongoCollectionAsJson
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    /* get */
    records = [];
    var cursor = db.getCollection('tasks').find({}, {});
    while(cursor.hasNext()) {
    records.push(cursor.next())
    }
    print(tojson(records));
    /* transfer */
    db.getCollection('tasks2').insertMany(tojson(records));