首页 > 代码库 > crud

crud

CRUD

create,read, update,delete

Operations

db.collection.count() 
db.collection.distinct()
db.collection.findOne()
db.collection.remove() 
db.collection.save() 
db.collection.update()

Cursors

cursor.count()
cursor.explain()
cursor.hint()
cursor.limit()
cursor.next()
cursor.skip()
cursor.sort()
cursor.toArray()

分析性能

// 分析查询的性能
db.inventory.find( { type: ‘food‘ } ).explain()
//  分析不同索引的性能
???db.inventory.find( { type: ‘food‘ } ).hint( { type: 1 } ).explain()
db.inventory.find( { type: ‘food‘ } ).hint( { type: 1, name: 1 } ).explain()

crud