cursor.forEach(function) 循环 比如cursor.forEach(function (obj) {printjson(obj);})
实现分页
cursor.skip(n) 跳过n行
cursor.limit(n) 显示n行
比如:显示第5页。一页10条
var cursor = db.stu.find().skip(5*9).limit(10);
转化为数组
cursor.toArray()
db.collectionName.reIndex() 重建索引
创建多列索引
db.stu.ensureIndex({age:1,stu_id:-1})
创建子文档索引
db.stu.ensureIndex({father.age:1})
创建唯一索引
db.stu.ensureIndex({stu_id:1},{unique:true})
创建哈希索引
db.stu.ensureIndex({name:’hashed’})
原文:http://www.cnblogs.com/yxwkf/p/5225286.html