文档型数据库,文件存储格式为BSON(JSON的扩展),自动分片,数据结构不预先定义。不适用于事务性系统如银行或会计系统,不适用于BI商业智能。语法类似面向对象的查询语言。
e.g.
db.createCollection("user");
db.user.insert({uid:1,username:"Falcon",age:25});
db.user.update({uid:1},{$set:{age:26}}) #age=26
db.user.update({uid:1},{$inc:{age:-1}}) #age=age-1
db.things.find({name:"mongo"}).forEach(function(x) {
print(tojson(x));}); # select * from things where name = "mongo"
db.things.sort({ts:-1}).limit(10); # select * from things order by ts desc limit 10
db.users.find({$or:[{age:{$gt:18,$lt:30}}, {count:{$in:[18,28]}}]},{name:1,age:1}) # select name, age from users where (age > 18 and age < 30 or count in (18,28))
db.things.ensureIndex({uid:1}); # create index