??xml version="1.0" encoding="utf-8" standalone="yes"?>黄色av网站在线免费观看,日韩精品一二,亚洲国产精品久久人人爱蜜臀http://www.aygfsteel.com/waterjava/category/48128.html闻道有先后,术业有专攻!zh-cnWed, 23 Mar 2011 06:47:10 GMTWed, 23 Mar 2011 06:47:10 GMT60mongo数据库的下蝲与安装(windows xp环境下)http://www.aygfsteel.com/waterjava/archive/2011/03/23/346832.html狼爱上狸狼爱上狸Wed, 23 Mar 2011 03:00:00 GMThttp://www.aygfsteel.com/waterjava/archive/2011/03/23/346832.htmlhttp://www.aygfsteel.com/waterjava/comments/346832.htmlhttp://www.aygfsteel.com/waterjava/archive/2011/03/23/346832.html#Feedback0http://www.aygfsteel.com/waterjava/comments/commentRss/346832.htmlhttp://www.aygfsteel.com/waterjava/services/trackbacks/346832.html1.下蝲数据?a style="color: #000000; text-decoration: none; outline-style: none; outline-width: initial; outline-color: initial; ">http://fastdl.mongodb.org/win32/mongodb-win32-i386-1.6.5.zip

2.现在完成后解压目录,攑ֈC盘下Q然后按照如下选择“我的电脑->属?>高->环境变量”Q将“C:\mongodb\bin”q个路径攑ֈ环境变量内(如果d环境变量可以ȝ上找Q?

3.选择"开?>q行"Q输?cmd"Q在DOSH口内输?#8220;mongod -port 27017 -dbpath D:/deployment/mongoDb/data/db -logpath D:/deployment/mongoDb/data/log/logs.log ”Q其中dbpath 为数据文件存储\径,logpath 为日志文件存储\径?/p>

4.不要关闭上面的窗口,新打开一个DOSQ输?#8220;mongo->use admin->db.AddUser(username,password)”,username:数据库数据集的用户名Qpassword数据库数据集操作的密码?/p>

5.在两个DOSH口内分别按“ctrl+c”Q在W一个DOSH口内输?#8220;mongod -port 27017 -dbpath D:/deployment/mongoDb/data/db -logpath D:/deployment/mongoDb/data/log/logs.log -logappend -auth”的启动命令,auth是要求操作数据集是需要验证?/p>

6.在第二个DOSH口内,输入“mongo->use admin->db.auth(username,password)”Q然后就可以Ҏ据集q行操作Q增、删、改Q?/p>


来自:http://www.hitb.com.cn/web/guest/bbs/-/message_boards/message/26944



狼爱上狸 2011-03-23 11:00 发表评论
]]>
win7 启动 mongo Ҏhttp://www.aygfsteel.com/waterjava/archive/2011/03/23/346822.html狼爱上狸狼爱上狸Wed, 23 Mar 2011 02:32:00 GMThttp://www.aygfsteel.com/waterjava/archive/2011/03/23/346822.htmlhttp://www.aygfsteel.com/waterjava/comments/346822.htmlhttp://www.aygfsteel.com/waterjava/archive/2011/03/23/346822.html#Feedback0http://www.aygfsteel.com/waterjava/comments/commentRss/346822.htmlhttp://www.aygfsteel.com/waterjava/services/trackbacks/346822.htmlhttp://www.360doc.com/content/10/0618/22/10626_33885376.shtml

狼爱上狸 2011-03-23 10:32 发表评论
]]>
mongo 命o?/title><link>http://www.aygfsteel.com/waterjava/archive/2011/03/23/346820.html</link><dc:creator>狼爱上狸</dc:creator><author>狼爱上狸</author><pubDate>Wed, 23 Mar 2011 02:31:00 GMT</pubDate><guid>http://www.aygfsteel.com/waterjava/archive/2011/03/23/346820.html</guid><wfw:comment>http://www.aygfsteel.com/waterjava/comments/346820.html</wfw:comment><comments>http://www.aygfsteel.com/waterjava/archive/2011/03/23/346820.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/waterjava/comments/commentRss/346820.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/waterjava/services/trackbacks/346820.html</trackback:ping><description><![CDATA[<span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">首先在mongo官网下蝲Windows的版?/span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">启动服务Qmongod.exe --port 12345 --dbpath=c:\mongodb\db</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">昄一下信息:</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">Fri Dec 04 14:30:32 Mongo DB : starting : pid = 0 port = 12345 dbpath = c:\mongo</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">db\db master = 0 slave = 0  32-bit</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">**       see http://blog.mongodb.org/post/137788967/32-bit-limitations for more</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">Fri Dec 04 14:30:32 db version v1.1.4-, pdfile version 4.5</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">Fri Dec 04 14:30:32 git version: c67c2f7dd681152f1784c8e1c2119b979e65881d</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">Fri Dec 04 14:30:32 sys info: windows (5, 1, 2600, 2, 'Service Pack 3') BOOST_LI</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">B_VERSION=1_35</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">Fri Dec 04 14:30:32 waiting for connections on port 12345</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">启动客户端:mongo.exe localhost:12345</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">查是否正?db.foo.save({a:1,b:9})</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">     db.foo.find({a:1})</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">控制台显C:{ "_id" : ObjectId("4b18b5b56f40000000006cec"), "a" : 1, "b" : 9 }</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">d数据Qdb.foo.save({a:1,b:9})</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">查询数据Qdb.foo.find({a:1})  //{a:1}是查询条Ӟ当ؓI时查询所?/span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">  db.foo.findOne({a:1}) //昄Z条数?/span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">删除数据Qdb.foo.remove({a:1}) //删除a=1的数?/span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">表的数据?db.foo.find().count()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">昄数据指定的条?db.foo.find().limit(n)</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">昄库名:db.foo.getDB()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">获取索引|db.foo.getIndexes()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">表的l计:db.foo.stats()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">删除?db.foo.drop()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">获取不重复的列:db.foo.distinct( key ) - eg. db.foo.distinct( 'x' )</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">忽略前面的几行:db.other.find({a:2}).skip(2)//忽略a=2中的前面2?/span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">Ҏ帮助:db.foo.help()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">HELP</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        show dbs                     show database names</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        show collections             show collections in current database</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        show users                   show users in current database</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        show profile                 show most recent system.profile entries with time >= 1ms</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        use <db name>                set curent database to <db name></span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.help()                    help on DB methods</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.help()                help on collection methods</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.find()                list objects in collection foo</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.find( { a : 1 } )     list objects in foo where a == 1</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        it                           result of the last line evaluated; use to further iterate</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">DB methods:</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.addUser(username, password)</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.auth(username, password)</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.cloneDatabase(fromhost)</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.commandHelp(name) returns the help for the command</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.copyDatabase(fromdb, todb, fromhost)</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.createCollection(name, { size : ..., capped : ..., max : ... } )</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.currentOp() displays the current operation in the db</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.dropDatabase()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.eval(func, args) run code server-side</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.getCollection(cname) same as db['cname'] or db.cname</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.getCollectionNames()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.getLastError() - just returns the err msg string</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.getLastErrorObj() - return full status object</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.getMongo() get the server connection object</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.getMongo().setSlaveOk() allow this connection to read from the nonmaster member of a replica pair</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.getName()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.getPrevError()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.getProfilingLevel()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.getReplicationInfo()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.getSisterDB(name) get the db at the same server as this onew</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.killOp() kills the current operation in the db</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.printCollectionStats()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.printReplicationInfo()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.printSlaveReplicationInfo()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.printShardingStatus()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.removeUser(username)</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.repairDatabase()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.resetError()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.runCommand(cmdObj) run a database command.  if cmdObj is a string, turns it into { cmdObj : 1 }</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.setProfilingLevel(level) 0=off 1=slow 2=all</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.shutdownServer()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.version() current version of the server</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">DBCollection help</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.count()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.dataSize()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.distinct( key ) - eg. db.foo.distinct( 'x' )</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.drop() drop the collection</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.dropIndex(name)</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.dropIndexes()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.ensureIndex(keypattern,options) - options should be an object with these possible fields: name, unique, dropDups</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.find( [query] , [fields]) - first parameter is an optional queryfilter. second parameter is optional set of fields to return.  e.g. db.foo.find( { x : 77 } , { name : 1 , x : 1 } )</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.find(...).count()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.find(...).limit(n)</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.find(...).skip(n)</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.find(...).sort(...)</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.findOne([query])</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.getDB() get DB object associated with collection</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.getIndexes()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.group( { key : ..., initial: ..., reduce : ...[, cond: ...] } )</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.mapReduce( mapFunction , reduceFunction , <optional params> )</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.remove(query)</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.renameCollection( newName ) renames the collection</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.save(obj)</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.stats()</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.storageSize() - includes free space allocated to this collection</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.totalIndexSize() - size in bytes of all the indexes</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.totalSize() - storage allocated for all data and indexes</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.update(query, object[, upsert_bool])</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.validate() - SLOW</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">        db.foo.getShardVersion() - only for use with sharding</span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span> <div><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span></div> <div><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">来自: </span><a >http://canofy.javaeye.com/blog/540926</a></div> <img src ="http://www.aygfsteel.com/waterjava/aggbug/346820.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/waterjava/" target="_blank">狼爱上狸</a> 2011-03-23 10:31 <a href="http://www.aygfsteel.com/waterjava/archive/2011/03/23/346820.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>mongo shell命ohttp://www.aygfsteel.com/waterjava/archive/2011/03/23/346819.html狼爱上狸狼爱上狸Wed, 23 Mar 2011 02:29:00 GMThttp://www.aygfsteel.com/waterjava/archive/2011/03/23/346819.htmlhttp://www.aygfsteel.com/waterjava/comments/346819.htmlhttp://www.aygfsteel.com/waterjava/archive/2011/03/23/346819.html#Feedback0http://www.aygfsteel.com/waterjava/comments/commentRss/346819.htmlhttp://www.aygfsteel.com/waterjava/services/trackbacks/346819.html命o?/h3>
--help 昄命o行参?/td>
--nodb 不连接数据库方式启动Q稍后可以?nbsp;new Mongo() ?nbsp;connect() 来徏立连?/td>
--shell 从命令行q行完一?.js 文g后,停留在shell中,而不是结?/td>

Ҏ命o

非JavaScript的辅助指令:

help 昄帮助
db.help() 昄 db Ҏ帮助
db.myColl .help() 昄聚集的方法帮?/td>
show dbs 打印服务器上所有数据库的列?/td>
use dbname 讄db变量来指明用服务器上的 dbname 数据?/td>
show collections 打印当前数据库的所有聚?/td>
show users 打印当前数据库的用户
show profile 打印最q耗时大于1ms的profiling操作

基本的Shell Javascript操作

db 指向当前数据库对象和q接的变量,已经在你的实例里定义好?/td>
db.auth(user,pass) 数据库认证(如果q行安全模式的话Q?/td>
coll = db.collection 讉K数据库里特定?nbsp;collection
cursor = coll.find() 查找聚集里所有的对象。参?nbsp;[查询] ?/td>
coll.remove(objpattern ) 从聚集里删除匚w的对象?nbsp;
objpattern 是一个指定匹配的域的对象Q例如:coll.remove( { name: "Joe" } );
coll.save(object ) 在聚集中保存对象Q如果已l存在的话则更新它?nbsp;
如果对象?presave ҎQ则会在保存到数据库之前Q插入和更新之前Q调用该Ҏ?/td>
coll.insert(object) 向聚集中插入对象。不会检查该对象是否已经存在聚集中(卻I不是 upsertQ?/td>
coll.update(...) 在聚集中更新对象。update() 有许多参敎ͼh?nbsp;更新 文档?/td>
coll.ensureIndex( { name : 1 } ) ?nbsp;name 建烦引。如果烦引存在则不做M事?/td>
coll.drop() 删除 coll 聚集
db.getSisterDB(name) q回当前q接的另一个数据库。它允许跨数据库查询Q例如:db.getSisterDB('production').getCollectionNames()

查询

coll.find() 查询所有文?/td>
it 循环上次 find() 调用q回的游?/td>
coll.find( criteria ); 查询聚集中匹?nbsp;criteria 的对象。例如:coll.find( { name: "Joe" } );
coll.findOne( criteria); 查询q返回一个对象。如果没有找到则q回 null。如果你只需要返回一个对象,q个Ҏ?nbsp;find() as limit(1) 效率更高。如果元素类型是字符Ԍ数字或时_你还可以使用正则表达式:coll.find( { name: /joe/i } );
coll.find( criteria, fields ); 查询对象里特定的域。例如:coll.find( {}, {name:true} );
coll.find().sort( {field :1[, field :1] }); 对返回结果进行排序(field ASCQ。?-1 表示 DESC?/td>
coll.find( criteria ).sort( { field : 1 } ) 查找匚w criteria 的对象,q对 field q行排序?/td>
coll.find( ... ).limit(n ) 限制l果q回 n 行。如果你只需要某几行数据Q推荐这样做来获得最优性能?/td>
coll.find( ... ).skip(n) 跌 n 行结果?/td>
coll.count() q回聚集里对象的L?/td>
coll.find( ... ).count() q回匚w该查询的对象L。注意,该返回会忽略 limit ?skip。比如有100行记录匹配该查询Q但是limit?0Q?tt>count() 仍会q回100。这比你自己循环更快Q但仍然需要消耗些旉?/td>

更多信息请参?nbsp;[查询] ?/p>

错误?/h3>
[{{db.getLastError()}}] q回上次操作的错?/td>
db.getPrevError() q回之前操作的错?/td>
db.resetError() 清除错误记录

理命o

db.cloneDatabase(fromhost) 从另外指定的L拯当前数据数据库。fromhost必须为noauth模式?/td>
db.copyDatabase(fromdb, todb, fromhost) 拯fromhost的fromdb数据库到当前服务器的todb数据库。fromhost必须为noauth模式?/td>
db.repairDatabase() 修复当前数据库。如果数据库很大则该操作会非常慢?/td>
db.addUser(user,pwd) l当前数据库d用户?/td>
db.getCollectionNames() 获得所有聚集的列表?/td>
db.dropDatabase() 删除当前数据库?/td>

打开额外q接

db = connect("<host>:<port>/<dbname>") 打开一个新的数据库q接。一个shell可能有多个连接,但是shell自动的getLastError只用?'db' 变量?/td>
conn = new Mongo("hostname") 打开一个新的服务器q接。然后可以?nbsp;getDB() 来选择一个数据库?/td>
db = conn.getDB("dbname") 对一个连接选择一个特定的数据库?/td>

其他

Object.bsonsize(db.foo.findOne()) 打印一个数据库对象的bson大小Qmongo 版本1.3及以上)
db.foo.findOne().bsonsize() 打印一个数据库对象的bson大小 (mongo 版本1.3之前)



狼爱上狸 2011-03-23 10:29 发表评论
]]>
mongo phpadmin客户?/title><link>http://www.aygfsteel.com/waterjava/archive/2011/03/23/346817.html</link><dc:creator>狼爱上狸</dc:creator><author>狼爱上狸</author><pubDate>Wed, 23 Mar 2011 02:28:00 GMT</pubDate><guid>http://www.aygfsteel.com/waterjava/archive/2011/03/23/346817.html</guid><wfw:comment>http://www.aygfsteel.com/waterjava/comments/346817.html</wfw:comment><comments>http://www.aygfsteel.com/waterjava/archive/2011/03/23/346817.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/waterjava/comments/commentRss/346817.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/waterjava/services/trackbacks/346817.html</trackback:ping><description><![CDATA[<span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">其实用mongo已经有些时候了Q之所以算初探Q是因ؓ用的不深入,主要是当中nosql中的ck-v用的Q用之取代了部分的ttQ原因很单,mongo中的数据格式虽然是bson的,不过在我q个pythonergQ这不明明就是纯天然?dict么!好吧Q我承认Q就是这个原因让我义无反֜C了mongoing之\(无论什么项目,用到存储自然而然的想用mongo)?/span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">mongo的优劣是在用的q程中逐步体验出来的,在这里就不评说了Q想要评的L接google?/span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><img src="http://iyuan.javaeye.com/images/smiles/icon_wink.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " alt="" /></span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">之前一直是直接在服务器端用pymongo或者mongo自带的shell做数据查看修改之cȝ操作Q突然发现这个实在不利于推广Q公司同事似乎本能的对这Unosql有稳定性上的怀疑。也好理解,看不到的Q通常是不可信?谁说的来着)?/span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">鉴于大伙都习惯了phpadmin玩mysql的光荣传l,如果mongo也有cM的东东,看v来也亲切些,个h感觉Ҏq也会有利些?/span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">额,说了q么多,好像q没有能q入C题,好吧Q说是初探,g有些标题党了Q其实就x荐下q个东东Q?/span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><a target="_blank" style="color: #108ac6; text-decoration: underline; ">http://code.google.com/p/rock-php/wiki/rock_mongo_zh#安装</a></span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">不错的mongodb phpadmin客户端,q支持中?我想q个q是蛮有利推q的)Q所谓初探,只不q是使用q东东换了个视角来看看Mongodb,感觉的确有些不一栗?/span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">不过Q值得注意到是Q装q玩意之前,q得为php装一个mongo的driveQ不q不要紧Q装完这个之后,讉K时会直接l个装drive的链接,q是蛮方便的?/span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><br /> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">额,我应该不标题党吧(臛_不是U碎的标题党。?/span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "><img src="http://iyuan.javaeye.com/images/smiles/icon_biggrin.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; " alt="" /></span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; "> </span><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">Q?/span> <div><span style="font-family: Arial, sans-serif, Helvetica, Tahoma; font-size: 12px; line-height: 18px; ">来自:</span><a >http://iyuan.javaeye.com/blog/799515</a></div> <img src ="http://www.aygfsteel.com/waterjava/aggbug/346817.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/waterjava/" target="_blank">狼爱上狸</a> 2011-03-23 10:28 <a href="http://www.aygfsteel.com/waterjava/archive/2011/03/23/346817.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>mongo常用操作http://www.aygfsteel.com/waterjava/archive/2011/03/23/346816.html狼爱上狸狼爱上狸Wed, 23 Mar 2011 02:26:00 GMThttp://www.aygfsteel.com/waterjava/archive/2011/03/23/346816.htmlhttp://www.aygfsteel.com/waterjava/comments/346816.htmlhttp://www.aygfsteel.com/waterjava/archive/2011/03/23/346816.html#Feedback0http://www.aygfsteel.com/waterjava/comments/commentRss/346816.htmlhttp://www.aygfsteel.com/waterjava/services/trackbacks/346816.htmlshell#查询
查询 name = "bruce" 的数?br style="line-height: normal; " /> db.users.find({ name : "bruce" });

条g操作W?br style="line-height: normal; " /> $gt : >
$lt : <
$gte: >=
$lte: <=
$ne : !=?lt;>
$in : in
$nin: not in
$all: all
$not: 反匹?1.3.3及以上版?

查询 name <> "bruce" and age >= 18 的数?br style="line-height: normal; " /> db.users.find({name: {$ne: "bruce"}, age: {$gte: 18}});

查询 creation_date > '2010-01-01' and creation_date <= '2010-12-31' 的数?br style="line-height: normal; " /> db.users.find({creation_date:{$gt:new Date(2010,0,1), $lte:new Date(2010,11,31)});

查询 age in (20,22,24,26) 的数?br style="line-height: normal; " /> db.users.find({age: {$in: [20,22,24,26]}});

查询 age取模10{于0 的数?br style="line-height: normal; " /> db.users.find('this.age % 10 == 0');
或?br style="line-height: normal; " /> db.users.find({age : {$mod : [10, 0]}});

匚w所?br style="line-height: normal; " /> db.users.find({favorite_number : {$all : [6, 8]}});
可以查询出{name: 'David', age: 26, favorite_number: [ 6, 8, 9 ] }
可以不查询出{name: 'David', age: 26, favorite_number: [ 6, 7, 9 ] }

查询不匹配name=B*带头的记?br style="line-height: normal; " /> db.users.find({name: {$not: /^B.*/}});
查询 age取模10不等? 的数?br style="line-height: normal; " /> db.users.find({age : {$not: {$mod : [10, 0]}}});

#q回部分字段
选择q回age和_id字段(_id字段L会被q回)
db.users.find({}, {age:1});
db.users.find({}, {age:3});
db.users.find({}, {age:true});
db.users.find({ name : "bruce" }, {age:1});
0为false, ?为true

选择q回age、address和_id字段
db.users.find({ name : "bruce" }, {age:1, address:1});

排除q回age、address和_id字段
db.users.find({}, {age:0, address:false});
db.users.find({ name : "bruce" }, {age:0, address:false});

数组元素个数判断
对于{name: 'David', age: 26, favorite_number: [ 6, 7, 9 ] }记录
匚wdb.users.find({favorite_number: {$size: 3}});
不匹配db.users.find({favorite_number: {$size: 2}});

$exists判断字段是否存在
查询所有存在name字段的记?br style="line-height: normal; " /> db.users.find({name: {$exists: true}});
查询所有不存在phone字段的记?br style="line-height: normal; " /> db.users.find({phone: {$exists: false}});

$type判断字段cd
查询所有name字段是字W类型的
db.users.find({name: {$type: 2}});
查询所有age字段是整型的
db.users.find({age: {$type: 16}});

对于字符字段Q可以用正则表辑ּ
查询以字母b或者B带头的所有记?br style="line-height: normal; " /> db.users.find({name: /^b.*/i});

$elemMatch(1.3.1及以上版?
为数l的字段中匹配其中某个元?/p>

Javascript查询?where查询
查询 age > 18 的记录,以下查询都一?br style="line-height: normal; " /> db.users.find({age: {$gt: 18}});
db.users.find({$where: "this.age > 18"});
db.users.find("this.age > 18");
f = function() {return this.age > 18} db.users.find(f);

排序sort()
以年龄升序asc
db.users.find().sort({age: 1});
以年龄降序desc
db.users.find().sort({age: -1});

限制q回记录数量limit()
q回5条记?br style="line-height: normal; " /> db.users.find().limit(5);
q回3条记录ƈ打印信息
db.users.find().limit(3).forEach(function(user) {print('my age is ' + user.age)});
l果
my age is 18
my age is 19
my age is 20

限制q回记录的开始点skip()
从第3条记录开始,q回5条记?limit 3, 5)
db.users.find().skip(3).limit(5);

查询记录条数count()
db.users.find().count();
db.users.find({age:18}).count();
以下q回的不?Q而是user表中所有的记录数量
db.users.find().skip(10).limit(5).count();
如果要返回限制之后的记录数量Q要使用count(true)或者count(?)
db.users.find().skip(10).limit(5).count(true);

分组group()
假设test表只有以下一条数?br style="line-height: normal; " /> { domain: "www.mongodb.org"
, invoked_at: {d:"2009-11-03", t:"17:14:05"}
, response_time: 0.05
, http_action: "GET /display/DOCS/Aggregation"
}
使用groupl计test?1月䆾的数据count:count(*)、total_time:sum(response_time)?avg_time:total_time/count;
db.test.group(
   { cond: {"invoked_at.d": {$gt: "2009-11", $lt: "2009-12"}}
   , key: {http_action: true}
   , initial: {count: 0, total_time:0}
   , reduce: function(doc, out){ out.count++; out.total_time+=doc.response_time }
   , finalize: function(out){ out.avg_time = out.total_time / out.count }
   } );

[
  {
    "http_action" : "GET /display/DOCS/Aggregation",
    "count" : 1,
    "total_time" : 0.05,
    "avg_time" : 0.05
  }
]

来自: http://hi.baidu.com/asminfo/blog/item/20301e22dcfcce50ac34de7a.html



狼爱上狸 2011-03-23 10:26 发表评论
]]>
grails 升?.3.6的ؕ码解x?/title><link>http://www.aygfsteel.com/waterjava/archive/2011/03/23/346815.html</link><dc:creator>狼爱上狸</dc:creator><author>狼爱上狸</author><pubDate>Wed, 23 Mar 2011 02:25:00 GMT</pubDate><guid>http://www.aygfsteel.com/waterjava/archive/2011/03/23/346815.html</guid><wfw:comment>http://www.aygfsteel.com/waterjava/comments/346815.html</wfw:comment><comments>http://www.aygfsteel.com/waterjava/archive/2011/03/23/346815.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/waterjava/comments/commentRss/346815.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/waterjava/services/trackbacks/346815.html</trackback:ping><description><![CDATA[<table style="table-layout: fixed; width: 960px; font-family: Arial; font-size: 12px; line-height: 18px; "> <tbody> <tr> <td style="font-family: Arial; word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: 18px; "> <div class="wmqeeuq" id="blog_text" class="cnt" style="font-family: Arial; word-wrap: break-word; word-break: normal; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 20px; color: #333333; overflow-x: hidden; overflow-y: hidden; position: static; "> <p style="line-height: normal; ">原先的grails?.2.0Q从q个版本之后Q我试过1.2.1Q?.2.2Q?.3.0Q?.3.1Q但都因为程序在q行时会变成qQ而一直用着1.2.0?/p> <p style="line-height: normal; ">我们的TOMCAT使用的是GBK~码QGRAILS文本都是使用UTF-8~码Q所以,q是产生q的根本原因?/p> <p style="line-height: normal; ">最q又有grails1.3.6Q更新得很快Q网上找了找Q有解决Ҏ了?a target="_blank" style="line-height: normal; ">http://www.groovyq.net/content/grails13%E5%8F%91%E5%B8%83</a></p> <p style="line-height: normal; ">在服务器上一试,果然能行。现记录如下Q?/p> <p style="line-height: normal; ">重新讑֮System.out的编码,下面语句加入到_GrailsInit.groovy中,或者加入工E的BootStrap.groovy的initD即?br style="line-height: normal; " /> System.out = new PrintStream(System.out, true,"GB2312");</p> <p style="line-height: normal; "> </p> <p style="line-height: normal; ">我用的是第二种ҎQ在BootStrap.groovy的initD中加入以上语句?/p> <p style="line-height: normal; ">以前Q有位高手也提到q,但他的原文是Q?/p> <p style="line-height: normal; ">“如果是println打印中文q的话Q那么就在初始化文g中增?br style="line-height: normal; " />  System.out = new  PrintStream(System.out, true, "GBK") <br style="line-height: normal; " /> 应该了Q你试一下吧Q?”</p> <p style="line-height: normal; ">所以我一直以为是解决打印q的?/p> <p style="line-height: normal; ">在此一q谢q?/p> <p style="line-height: normal; "><br /> </p> <p style="line-height: normal; ">来自: <span style="line-height: 20px; "><a >http://hi.baidu.com/caihexi/blog/item/76d093a4cce0c6e59152ee15.html</a></span></p> </div> </td> </tr> </tbody> </table> <img src ="http://www.aygfsteel.com/waterjava/aggbug/346815.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/waterjava/" target="_blank">狼爱上狸</a> 2011-03-23 10:25 <a href="http://www.aygfsteel.com/waterjava/archive/2011/03/23/346815.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MongoDB的基本操?/title><link>http://www.aygfsteel.com/waterjava/archive/2011/03/23/346814.html</link><dc:creator>狼爱上狸</dc:creator><author>狼爱上狸</author><pubDate>Wed, 23 Mar 2011 02:24:00 GMT</pubDate><guid>http://www.aygfsteel.com/waterjava/archive/2011/03/23/346814.html</guid><wfw:comment>http://www.aygfsteel.com/waterjava/comments/346814.html</wfw:comment><comments>http://www.aygfsteel.com/waterjava/archive/2011/03/23/346814.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/waterjava/comments/commentRss/346814.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/waterjava/services/trackbacks/346814.html</trackback:ping><description><![CDATA[详细请阅:  <div><a >http://www.oschina.net/code/snippet_35115_2888</a></div> <img src ="http://www.aygfsteel.com/waterjava/aggbug/346814.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/waterjava/" target="_blank">狼爱上狸</a> 2011-03-23 10:24 <a href="http://www.aygfsteel.com/waterjava/archive/2011/03/23/346814.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MongoDB的自增长主键的实?/title><link>http://www.aygfsteel.com/waterjava/archive/2011/03/23/346813.html</link><dc:creator>狼爱上狸</dc:creator><author>狼爱上狸</author><pubDate>Wed, 23 Mar 2011 02:23:00 GMT</pubDate><guid>http://www.aygfsteel.com/waterjava/archive/2011/03/23/346813.html</guid><wfw:comment>http://www.aygfsteel.com/waterjava/comments/346813.html</wfw:comment><comments>http://www.aygfsteel.com/waterjava/archive/2011/03/23/346813.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/waterjava/comments/commentRss/346813.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/waterjava/services/trackbacks/346813.html</trackback:ping><description><![CDATA[详细请阅:  <div><a >http://www.oschina.net/code/snippet_35115_2915</a></div> <img src ="http://www.aygfsteel.com/waterjava/aggbug/346813.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/waterjava/" target="_blank">狼爱上狸</a> 2011-03-23 10:23 <a href="http://www.aygfsteel.com/waterjava/archive/2011/03/23/346813.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>mongo的初体验http://www.aygfsteel.com/waterjava/archive/2011/03/23/346812.html狼爱上狸狼爱上狸Wed, 23 Mar 2011 02:22:00 GMThttp://www.aygfsteel.com/waterjava/archive/2011/03/23/346812.htmlhttp://www.aygfsteel.com/waterjava/comments/346812.htmlhttp://www.aygfsteel.com/waterjava/archive/2011/03/23/346812.html#Feedback0http://www.aygfsteel.com/waterjava/comments/commentRss/346812.htmlhttp://www.aygfsteel.com/waterjava/services/trackbacks/346812.html首先在mongo官网下蝲Windows的版?/span> 

启动服务Qmongod.exe --port 12345 --dbpath=c:\mongodb\db 
昄一下信息: 
Fri Dec 04 14:30:32 Mongo DB : starting : pid = 0 port = 12345 dbpath = c:\mongo 
db\db master = 0 slave = 0  32-bit 

** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data 

**       see http://blog.mongodb.org/post/137788967/32-bit-limitations for more 

Fri Dec 04 14:30:32 db version v1.1.4-, pdfile version 4.5 
Fri Dec 04 14:30:32 git version: c67c2f7dd681152f1784c8e1c2119b979e65881d 
Fri Dec 04 14:30:32 sys info: windows (5, 1, 2600, 2, 'Service Pack 3') BOOST_LI 
B_VERSION=1_35 
Fri Dec 04 14:30:32 waiting for connections on port 12345 


启动客户端:mongo.exe localhost:12345 

查是否正?db.foo.save({a:1,b:9}) 
     db.foo.find({a:1}) 
控制台显C:{ "_id" : ObjectId("4b18b5b56f40000000006cec"), "a" : 1, "b" : 9 } 


d数据Qdb.foo.save({a:1,b:9}) 

查询数据Qdb.foo.find({a:1})  //{a:1}是查询条Ӟ当ؓI时查询所?/span> 
  db.foo.findOne({a:1}) //昄Z条数?/span> 

删除数据Qdb.foo.remove({a:1}) //删除a=1的数?/span> 

表的数据?db.foo.find().count() 

昄数据指定的条?db.foo.find().limit(n) 

昄库名:db.foo.getDB() 

获取索引|db.foo.getIndexes() 

表的l计:db.foo.stats() 

删除?db.foo.drop() 

获取不重复的列:db.foo.distinct( key ) - eg. db.foo.distinct( 'x' ) 

忽略前面的几行:db.other.find({a:2}).skip(2)//忽略a=2中的前面2?/span> 

Ҏ帮助:db.foo.help() 


HELP 
        show dbs                     show database names 
        show collections             show collections in current database 
        show users                   show users in current database 
        show profile                 show most recent system.profile entries with time >= 1ms 
        use <db name>                set curent database to <db name> 
        db.help()                    help on DB methods 
        db.foo.help()                help on collection methods 
        db.foo.find()                list objects in collection foo 
        db.foo.find( { a : 1 } )     list objects in foo where a == 1 
        it                           result of the last line evaluated; use to further iterate 


DB methods: 
        db.addUser(username, password) 
        db.auth(username, password) 
        db.cloneDatabase(fromhost) 
        db.commandHelp(name) returns the help for the command 
        db.copyDatabase(fromdb, todb, fromhost) 
        db.createCollection(name, { size : ..., capped : ..., max : ... } ) 
        db.currentOp() displays the current operation in the db 
        db.dropDatabase() 
        db.eval(func, args) run code server-side 
        db.getCollection(cname) same as db['cname'] or db.cname 
        db.getCollectionNames() 
        db.getLastError() - just returns the err msg string 
        db.getLastErrorObj() - return full status object 
        db.getMongo() get the server connection object 
        db.getMongo().setSlaveOk() allow this connection to read from the nonmaster member of a replica pair 
        db.getName() 
        db.getPrevError() 
        db.getProfilingLevel() 
        db.getReplicationInfo() 
        db.getSisterDB(name) get the db at the same server as this onew 
        db.killOp() kills the current operation in the db 
        db.printCollectionStats() 
        db.printReplicationInfo() 
        db.printSlaveReplicationInfo() 
        db.printShardingStatus() 
        db.removeUser(username) 
        db.repairDatabase() 
        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() current version of the server 

DBCollection help 
        db.foo.count() 
        db.foo.dataSize() 
        db.foo.distinct( key ) - eg. db.foo.distinct( 'x' ) 
        db.foo.drop() drop the collection 
        db.foo.dropIndex(name) 
        db.foo.dropIndexes() 
        db.foo.ensureIndex(keypattern,options) - options should be an object with these possible fields: name, unique, dropDups 
        db.foo.find( [query] , [fields]) - first parameter is an optional queryfilter. second parameter is optional set of fields to return.  e.g. db.foo.find( { x : 77 } , { name : 1 , x : 1 } ) 
        db.foo.find(...).count() 
        db.foo.find(...).limit(n) 
        db.foo.find(...).skip(n) 
        db.foo.find(...).sort(...) 
        db.foo.findOne([query]) 
        db.foo.getDB() get DB object associated with collection 
        db.foo.getIndexes() 
        db.foo.group( { key : ..., initial: ..., reduce : ...[, cond: ...] } ) 
        db.foo.mapReduce( mapFunction , reduceFunction , <optional params> ) 
        db.foo.remove(query) 
        db.foo.renameCollection( newName ) renames the collection 
        db.foo.save(obj) 
        db.foo.stats() 
        db.foo.storageSize() - includes free space allocated to this collection 
        db.foo.totalIndexSize() - size in bytes of all the indexes 
        db.foo.totalSize() - storage allocated for all data and indexes 
        db.foo.update(query, object[, upsert_bool]) 
        db.foo.validate() - SLOW 
        db.foo.getShardVersion() - only for use with shardin

狼爱上狸 2011-03-23 10:22 发表评论
]]>
վ֩ģ壺 | | | | | ˷| ɽ| | | | | Դ| | | ӡ| ̨| | ӱ| | | | | Ž| | ɽ| | | ͤ| | | | Ͽ| | ī| ͼľ| | | | | | |