> db.nettuts.insert({ ... first: 'matthew', ... last: 'setter', ... dob: '21/04/1978', ... gender: 'm', ... hair_colour: 'brown', ... occupation: 'developer', ... nationality: 'australian' ... }); > db.nettuts.insert({ ... first: 'james', ... last: 'caan', ... dob: '26/03/1940', ... gender: 'm', ... hair_colour: 'brown', ... occupation: 'actor', ... nationality: 'american' ... }); > db.nettuts.insert({ ... first: 'arnold', ... last: 'schwarzenegger', ... dob: '03/06/1925', ... gender: 'm', ... hair_colour: 'brown', ... occupation: 'actor', ... nationality: 'american' ... }); > db.nettuts.insert({ ... first: 'tony', ... last: 'curtis', ... dob: '21/04/1978', ... gender: 'm', ... hair_colour: 'brown', ... occupation: 'developer', ... nationality: 'american' ... }); > db.nettuts.insert({ ... first: 'jamie lee', ... last: 'curtis', ... dob: '22/11/1958', ... gender: 'f', ... hair_colour: 'brown', ... occupation: 'actor', ... nationality: 'american' ... }); > db.nettuts.insert({ ... first: 'michael', ... last: 'caine', ... dob: '14/03/1933', ... gender: 'm', ... hair_colour: 'brown', ... occupation: 'actor', ... nationality: 'english' ... }); > db.nettuts.insert({ ... first: 'judi', ... last: 'dench', ... dob: '09/12/1934', ... gender: 'f', ... hair_colour: 'white', ... occupation: 'actress', ... nationality: 'english' ... }); > > > db.nettuts.find() { "_id" : ObjectId("5262042c4e857313accd7e7e"), "first" : "matthew", "last" : "setter", "dob" : "21/04/1978", "gender" : "m", "hair_colour" : "brown", "occupation" : "developer", "nationality" : "australian" } { "_id" : ObjectId("5262042c4e857313accd7e7f"), "first" : "james", "last" : "caan", "dob" : "26/03/1940", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e80"), "first" : "arnold", "last" : "schwarzenegger", "dob" : "03/06/1925", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e81"), "first" : "tony", "last" : "curtis", "dob" : "21/04/1978", "gender" : "m", "hair_colour" : "brown", "occupation" : "developer", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e82"), "first" : "jamie lee", "last" : "curtis", "dob" : "22/11/1958", "gender" : "f", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e83"), "first" : "michael", "last" : "caine", "dob" : "14/03/1933", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "english" } { "_id" : ObjectId("5262042e4e857313accd7e84"), "first" : "judi", "last" : "dench", "dob" : "09/12/1934", "gender" : "f", "hair_colour" : "white", "occupation" : "actress", "nationality" : "english" } > > > > db.nettuts.find() { "_id" : ObjectId("5262042c4e857313accd7e7e"), "first" : "matthew", "last" : "setter", "dob" : "21/04/1978", "gender" : "m", "hair_colour" : "brown", "occupation" : "developer", "nationality" : "australian" } { "_id" : ObjectId("5262042c4e857313accd7e7f"), "first" : "james", "last" : "caan", "dob" : "26/03/1940", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e80"), "first" : "arnold", "last" : "schwarzenegger", "dob" : "03/06/1925", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e81"), "first" : "tony", "last" : "curtis", "dob" : "21/04/1978", "gender" : "m", "hair_colour" : "brown", "occupation" : "developer", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e82"), "first" : "jamie lee", "last" : "curtis", "dob" : "22/11/1958", "gender" : "f", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e83"), "first" : "michael", "last" : "caine", "dob" : "14/03/1933", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "english" } { "_id" : ObjectId("5262042e4e857313accd7e84"), "first" : "judi", "last" : "dench", "dob" : "09/12/1934", "gender" : "f", "hair_colour" : "white", "occupation" : "actress", "nationality" : "english" } > > > > > > db.nettuts.find({gender: 'f'}); { "_id" : ObjectId("5262042c4e857313accd7e82"), "first" : "jamie lee", "last" : "curtis", "dob" : "22/11/1958", "gender" : "f", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "american" } { "_id" : ObjectId("5262042e4e857313accd7e84"), "first" : "judi", "last" : "dench", "dob" : "09/12/1934", "gender" : "f", "hair_colour" : "white", "occupation" : "actress", "nationality" : "english" } > > > db.nettuts.find({gender: 'm'}); { "_id" : ObjectId("5262042c4e857313accd7e7e"), "first" : "matthew", "last" : "setter", "dob" : "21/04/1978", "gender" : "m", "hair_colour" : "brown", "occupation" : "developer", "nationality" : "australian" } { "_id" : ObjectId("5262042c4e857313accd7e7f"), "first" : "james", "last" : "caan", "dob" : "26/03/1940", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e80"), "first" : "arnold", "last" : "schwarzenegger", "dob" : "03/06/1925", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e81"), "first" : "tony", "last" : "curtis", "dob" : "21/04/1978", "gender" : "m", "hair_colour" : "brown", "occupation" : "developer", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e83"), "first" : "michael", "last" : "caine", "dob" : "14/03/1933", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "english" } > > > > > db.nettuts.find({gender: 'm', $or: [{nationality: 'english'}]}); { "_id" : ObjectId("5262042c4e857313accd7e83"), "first" : "michael", "last" : "caine", "dob" : "14/03/1933", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "english" } > > db.nettuts.find({gender: 'm', $or: [{nationality: 'english'}, {nationality: 'american'}]}); { "_id" : ObjectId("5262042c4e857313accd7e7f"), "first" : "james", "last" : "caan", "dob" : "26/03/1940", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e80"), "first" : "arnold", "last" : "schwarzenegger", "dob" : "03/06/1925", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e81"), "first" : "tony", "last" : "curtis", "dob" : "21/04/1978", "gender" : "m", "hair_colour" : "brown", "occupation" : "developer", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e83"), "first" : "michael", "last" : "caine", "dob" : "14/03/1933", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "english" } > > > > > db.nettuts.find({gender: 'm', $or: [{nationality: 'english'}, {nationality: 'american'}]}).sort({nationality: -1}); { "_id" : ObjectId("5262042c4e857313accd7e83"), "first" : "michael", "last" : "caine", "dob" : "14/03/1933", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "english" } { "_id" : ObjectId("5262042c4e857313accd7e7f"), "first" : "james", "last" : "caan", "dob" : "26/03/1940", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e80"), "first" : "arnold", "last" : "schwarzenegger", "dob" : "03/06/1925", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e81"), "first" : "tony", "last" : "curtis", "dob" : "21/04/1978", "gender" : "m", "hair_colour" : "brown", "occupation" : "developer", "nationality" : "american" } > > > db.nettuts.find({gender: 'm', $or: [{nationality: 'english'}, {nationality: 'american'}]}).sort({nationality: -1, first: 1}); { "_id" : ObjectId("5262042c4e857313accd7e83"), "first" : "michael", "last" : "caine", "dob" : "14/03/1933", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "english" } { "_id" : ObjectId("5262042c4e857313accd7e80"), "first" : "arnold", "last" : "schwarzenegger", "dob" : "03/06/1925", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e7f"), "first" : "james", "last" : "caan", "dob" : "26/03/1940", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e81"), "first" : "tony", "last" : "curtis", "dob" : "21/04/1978", "gender" : "m", "hair_colour" : "brown", "occupation" : "developer", "nationality" : "american" } > > > > > db.nettuts.find({gender: 'm', $or: [{nationality: 'english'}, {nationality: 'american'}]}).limit(2); { "_id" : ObjectId("5262042c4e857313accd7e7f"), "first" : "james", "last" : "caan", "dob" : "26/03/1940", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e80"), "first" : "arnold", "last" : "schwarzenegger", "dob" : "03/06/1925", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "american" } > > > > > db.nettuts.find({gender: 'm', $or: [{nationality: 'english'}, {nationality: 'american'}]}).limit(2).skip(2); { "_id" : ObjectId("5262042c4e857313accd7e81"), "first" : "tony", "last" : "curtis", "dob" : "21/04/1978", "gender" : "m", "hair_colour" : "brown", "occupation" : "developer", "nationality" : "american" } { "_id" : ObjectId("5262042c4e857313accd7e83"), "first" : "michael", "last" : "caine", "dob" : "14/03/1933", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "english" } > > > > > db.nettuts.update({first: 'james', last: 'caan'}, {$set: {hair_colour: 'brown'}}); > > > db.nettuts.find({first: 'james', last: 'caan'}); { "_id" : ObjectId("5262042c4e857313accd7e7f"), "first" : "james", "last" : "caan", "dob" : "26/03/1940", "gender" : "m", "hair_colour" : "brown", "occupation" : "actor", "nationality" : "american" } > > > > > db.nettuts.remove({first: 'james', last: 'caan'}); > > > db.nettuts.find({first: 'james', last: 'caan'}); > > > > db.nettuts.remove(); > > db.nettuts.find(); >