db.AddUser(username,password)
db.auth(usrename,password)
db.cloneDataBase(fromhost)
db.commandHelp(name)
db.copyDatabase(fromdb,todb,fromhost)
db.createCollection(name,{size:3333,capped:333,max:88888})
db.currentOp()
db.dropDataBase()
db.eval_r(func,args)
db.getCollection(cname)
db.getCollenctionNames()
db.getLastError()
db.getLastErrorObj()
db.getMongo()
db.getMondo().setSlaveOk()
db.getName()
db.getPrevError()
db.getProfilingLevel()
db.getReplicationInfo()
db.getSisterDB(name)
db.killOp()
db.printCollectionStats()
db.printReplicationInfo()
db.printSlaveReplicationInf
db.printShardingStatus()
db.removeUser(username)
db.repairDatabase()
db.resetError()
db.runCommand(cmdObj)
db.setProfilingLevel(level)
db.shutdownServer()
db.version()
db.test.find({id:10})
db.test.find({id:10}).count()
db.test.find({id:10}).limit(2) 返回test数据集ID=10的数据集从第二条开始的数据集
db.test.find({id:10}).skip(8)
db.test.find({id:10}).limit(2).skip(8)
db.test.find({id:10}).sort()
db.test.findOne([query])
db.test.getDB()
db.test.getIndexes()
db.test.group({key:...,initial:...,reduce:...[,cond:...]})
db.test.mapReduce(mayFunction,reduceFunction,)
db.test.remove(query)
db.test.renameCollection(newName)
db.test.save(obj)
db.test.stats()
db.test.storageSize()
db.test.totalIndexSize()
db.test.totalSize()
db.test.update(query,object[,upsert_bool]) 在此数据集中更新一条数据
db.test.validate()
db.test.getShardVersion()
MongoDB语法
db.test.find({'name':'foobar'}) <==> select * from test where name='foobar'
db.test.find()
db.test.find({'ID':10}).count() <==> select count(*) from test where ID=10
db.test.find().skip(10).limit(20)
db.test.find({'ID':{$in:[25,35,45]}}) <==> select * from test where ID in (25,35,45)
db.test.find().sort({'ID':-1})
db.test.distinct('name',{'ID':{$lt:20}})
db.test.group({key:{'name':true},cond:{'name':'foo'},reduce:function(obj,prev){prev.msum+=obj.marks;},initial:{msum:0}})
db.test.find('this.ID<20',{name:1})
db.test.insert({'name':'foobar','age':25})<==>insert into test ('name','age') values('foobar',25)
db.test.remove({})
db.test.remove({'age':20})
db.test.remove({'age':{$lt:20}})
db.test.remove({'age':{$lte:20}}) <==> delete test where age<=20
db.test.remove({'age':{$gt:20}})
db.test.remove({'age':{$gte:20}}) <==> delete test where age>=20
db.test.remove({'age':{$ne:20}})
db.test.update({'name':'foobar'},{$set:{'age':36}}) <==> update test set age=36 where name='foobar'
db.test.update({'name':'foobar'},{$inc:{'age':3}})
注意以上命令大小写敏感