Skip to content

Instantly share code, notes, and snippets.

@sushilshah
sushilshah / ShardSvrSetup for Win
Created January 10, 2013 07:33
10gen-MongoDB
rem for windows
set mongod=start /MIN mongod
set mongos=start /MIN mongos
set name=%COMPUTERNAME%
mkdir a0
mkdir a1
mkdir a2
mkdir b0
mkdir b1
//Setup directories
mkdir r1
mkdir r2
mkdir r3
mkdir r4
mkdir r5
mkdir r6
mkdir config
//create replicasets
@sushilshah
sushilshah / example.js
Created November 19, 2012 15:50 — forked from philipp-spiess/example.js
MongoDB CRUD and MapReduce
db.foo.insert( { name: "Mario", fach: ["E", "D"] } );
db.foo.insert( { name: "Philipp", fach: ["PR", "D"] } );
db.foo.find();
db.foo.find( { name: "Mario" } );
db.foo.find( { fach: { $in : [ "E", "M" ] } } );
db.foo.update( { name: "Mario" }, { $push: { fach: "M" } } );
db.foo.find( { name: "Mario" } );
@sushilshah
sushilshah / example2.js
Created November 19, 2012 15:47 — forked from anonymous/example2.js
MongoDB map reduce example 2
// suggested shell cmd line to run this:
//
// mongo --shell example2.js
//
// Note: the { out : … } parameter is for mongodb 1.8+
db.things.insert( { _id : 1, tags : ['dog', 'cat'] } );
db.things.insert( { _id : 2, tags : ['cat'] } );
db.things.insert( { _id : 3, tags : ['mouse', 'cat', 'dog'] } );
db.things.insert( { _id : 4, tags : [] } );