Snippets

Find

// db.collection.find(query, projection)
db.Users.find(
  { status: "A" },
  { user_id: 1, status: 1, _id: 0 }
)
db.Users.find(
  { age: { $gt: 25 } }
)
db.Users.find( { status: /^bc/ } ).sort( { user_id: 1 } )

db.Users.find().limit(5).skip(10)

Count

// db.collection.count(query)
db.Users.count( { user_id: { $exists: true } } )
db.Users.count( { age: { $gt: 30 } } )

Distinct

// db.collection.distinct(field, query, options)
db.Users.distinct( "status" )
db.Article.distinct("Comment.Reply.ip", {"Comment.Reply.email" : /gmail/})

MongoDB

Getting Started

Thinking in Documents: Part 1

RDBMS to MongoDB Migration Guide

RDBMS --- MongoDB
Table Collection
Row Document
Column Field

MongoDB stores JSON documents in a binaryrepresentation called BSON (Binary JSON).

Object Relational Mappers

docs.mongodb.com/manual/reference/command/mapReduce