参考网站, http://www.100720.com/java_category/mongodb
使用心得:
1,db.help 回车(可以得到如下函数)
2,数据库命令:
1.db.lcc.update({id:1},{$inc:{x:1}},false,true)
db.runCommand({getLastError:1})
3.删除一个文档名叫lcc,下面三种方式
db.lcc.drop() <==> db.runCommand({"drop":"lcc"}) <==> db.$cmd.findone({"drop":"lcc"})
4,db.listCommands() 会列出很多命令
buildInfo:{"buildInfo":1}
collStatus:{"collStatus":collectionName}
drop:{"drop":collectionName}
dropDatabase:{"dropDatabase":1} 删除当前数据库下所有数据
dropIndexes:{"dropIndexes":collectionName,"index":indexName}
findAndModify:
isMaster:{"isMaster",1} 检测本服务器是是主服务器还是从服务器
listCommands:{"listCommands":1} 放回可以在服务器上运行的命令及相关信息
listDatabases:{"listDatabases":1}
ping:{"ping":1} 检测服务器连接是否正常,即便服务器上锁了,这条命令也回立即返回
renameCollection:{"renameCollection":a,"to":b} 将集合a重命名为b,几种a,b必须是完整的集合命名空间(eg:foo.bar 表示foo数据库下的bar集合)
serverStatus:{"serverStatus":1} 返回这台服务器的管理统计信息