日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

mongo api

發(fā)布時間:2025/3/20 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mongo api 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

轉(zhuǎn)載:http://dxsoft.cnblogs.com/



mongo –path
db.AddUser(username,password) 添加用戶
db.auth(usrename,password) 設置數(shù)據(jù)庫連接驗證
db.cloneDataBase(fromhost) 從目標服務器克隆一個數(shù)據(jù)庫
db.commandHelp(name) returns the help for the command
db.copyDatabase(fromdb,todb,fromhost) 復制數(shù)據(jù)庫fromdb—源數(shù)據(jù)庫名稱,todb—目標數(shù)據(jù)庫名稱,fromhost—源數(shù)據(jù)庫服務器地址
db.createCollection(name,{size:3333,capped:333,max:88888}) 創(chuàng)建一個數(shù)據(jù)集,相當于一個表
db.currentOp() 取消當前庫的當前操作
db.dropDataBase() 刪除當前數(shù)據(jù)庫
db.eval(func,args) run code server-side
db.getCollection(cname) 取得一個數(shù)據(jù)集合,同用法:db['cname'] or db.cname
db.getCollenctionNames() 取得所有數(shù)據(jù)集合的名稱列表
db.getLastError() 返回最后一個錯誤的提示消息
db.getLastErrorObj() 返回最后一個錯誤的對象
db.getMongo() 取得當前服務器的連接對象get the server connection object
db.getMondo().setSlaveOk() allow this connection to read from then nonmaster membr of a replica pair
db.getName() 返回當操作數(shù)據(jù)庫的名稱
db.getPrevError() 返回上一個錯誤對象
db.getProfilingLevel() ?什么等級
db.getReplicationInfo() ?什么信息
db.getSisterDB(name) get the db at the same server as this onew
db.killOp() 停止(殺死)在當前庫的當前操作
db.printCollectionStats() 返回當前庫的數(shù)據(jù)集狀態(tài)
db.printReplicationInfo()
db.printSlaveReplicationInfo()
db.printShardingStatus() 返回當前數(shù)據(jù)庫是否為共享數(shù)據(jù)庫
db.removeUser(username) 刪除用戶
db.repairDatabase() 修復當前數(shù)據(jù)庫
db.resetError()
db.runCommand(cmdObj) run a database command. if cmdObj is a string, turns it into {cmdObj:1}
db.setProfilingLevel(level) 0=off,1=slow,2=all
db.shutdownServer() 關閉當前服務程序
db.version() 返回當前程序的版本信息

db.linlin.find({id:10}) 返回linlin數(shù)據(jù)集ID=10的數(shù)據(jù)集
db.linlin.find({id:10}).count() 返回linlin數(shù)據(jù)集ID=10的數(shù)據(jù)總數(shù)
db.linlin.find({id:10}).limit(2)返回linlin數(shù)據(jù)集ID=10的數(shù)據(jù)集從第二條開始的數(shù)據(jù)集
db.linlin.find({id:10}).skip(8) 返回linlin數(shù)據(jù)集ID=10的數(shù)據(jù)集從0到第八條的數(shù)據(jù)集
db.linlin.find({id:10}).limit(2).skip(8) 返回linlin數(shù)據(jù)集ID=1=的數(shù)據(jù)集從第二條到第八條的數(shù)據(jù)
db.linlin.find({id:10}).sort() 返回linlin數(shù)據(jù)集ID=10的排序數(shù)據(jù)集
db.linlin.findOne([query]) 返回符合條件的一條數(shù)據(jù)
db.linlin.getDB() 返回此數(shù)據(jù)集所屬的數(shù)據(jù)庫名稱
db.linlin.getIndexes() 返回些數(shù)據(jù)集的索引信息
db.linlin.group({key:…,initial:…,reduce:…[,cond:...]})
db.linlin.mapReduce(mayFunction,reduceFunction,
)
db.linlin.remove(query) 在數(shù)據(jù)集中刪除一條數(shù)據(jù)
db.linlin.renameCollection(newName) 重命名些數(shù)據(jù)集名稱
db.linlin.save(obj) 往數(shù)據(jù)集中插入一條數(shù)據(jù)
db.linlin.stats() 返回此數(shù)據(jù)集的狀態(tài)
db.linlin.storageSize() 返回此數(shù)據(jù)集的存儲大小
db.linlin.totalIndexSize() 返回此數(shù)據(jù)集的索引文件大小
db.linlin.totalSize() 返回些數(shù)據(jù)集的總大小
db.linlin.update(query,object[,upsert_bool])在此數(shù)據(jù)集中更新一條數(shù)據(jù)
db.linlin.validate() 驗證此數(shù)據(jù)集
db.linlin.getShardVersion() 返回數(shù)據(jù)集共享版本號
db.linlin.find({‘name’:'foobar’}) select * from linlin where name=’foobar’
db.linlin.find() select * from linlin
db.linlin.find({‘ID’:10}).count() select count(*) from linlin where ID=10
db.linlin.find().skip(10).limit(20) 從查詢結果的第十條開始讀20條數(shù)據(jù) select * from linlin limit 10,20 ———-mysql
db.linlin.find({‘ID’:{in:[25,35,45]}})?select?*?from?linlin?where?ID?in?(25,35,45)?
db.linlin.find().sort({‘ID’:-1})?select?*?from?linlin?order?by?ID?desc?
db.linlin.distinct(‘name’,{‘ID’:{
lt:20}}) select distinct(name) from linlin where ID<20
db.linlin.group({key:{'name':true},cond:{'name':'foo'},reduce:function(obj,prev){prev.msum+=obj.marks;},initial:{msum:0}})
select name,sum(marks) from linlin group by name
db.linlin.find('this.ID<20′,{name:1}) select name from linlin where ID<20
db.linlin.insert({'name':'foobar’,'age':25}) insert into linlin ('name','age’)values('foobar',25)
db.linlin.insert({'name':'foobar’,'age':25,’email’:'cclove2@163.com’})
db.linlin.remove({}) delete * from linlin
db.linlin.remove({'age':20}) delete linlin where age=20
db.linlin.remove({'age':{lt:20}})?delete?linlin?where?age<20?
db.linlin.remove({'age':{
lte:20}}) delete linlin where age<=20
db.linlin.remove({'age':{gt:20}})?delete?linlin?where?age>20?
db.linlin.remove({‘a(chǎn)ge’:{
gte:20}}) delete linlin where age>=20
db.linlin.remove({‘a(chǎn)ge’:{ne:20}})?delete?linlin?where?age!=20?
db.linlin.update({‘name’:'foobar’},{‘
set’:{‘a(chǎn)ge’:36}}) update linlin set age=36 where name=’foobar’
db.linlin.update({‘name’:'foobar’},{‘$inc’:{‘a(chǎn)ge’:3}}) update linlin set age=age+3 where name=’foobar’


轉(zhuǎn)載于:https://blog.51cto.com/goooood/1663164

總結

以上是生活随笔為你收集整理的mongo api的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。