Mongo cheatsheet(速查页)

Mongo cheatsheet:

 
JSON-style documents with dynamic schemas offer simplicity and power.
 
>show dbs;
>show collections
 
>db.createCollection("mycoll", {capped:true, size:100000}) // Size is in bytes
>db.blog.save({ title : "My First Post", author: {name : "Jane", id : 1}})
>a = {title:"edmond blog", author:{name:"edmond", id:2}});
>db.blog.save(a);
 
create index
>db.blog.ensureIndex({author.name:1});  "B-Tree" indexes.
 
>db.blog.findOne({"author.name" : "Jane"})
db.blog.remove({n:1}); // removes all where n == 1
 
 
> var mongo = db.blog.findOne({title :"edmond blog"});
> print(tojson(mongo));
 

你可能感兴趣的:(职场,休闲,速查,cheatsheat)