日期:2014-05-16 浏览次数:20686 次
%mongodb_path%\bin\mongod.exe -dbpath e:\dbpath
%mongodb_path%\bin\mongo.exe
use mydb
db.testData.insert({x:1}) db.testData.insert({y:"mongo"})
show collections
db.testData.find()
for (var i = 1; i <= 25; i++) db.testData.insert( { x : i } )
var c=db.testData.find() while (c.hasNext()) printjson(c.next()) printjson(c[4])
db.testData.find({x:18}) db.testData.findOne() db.testData.find().limit(3)
function insertData(dbName, colName, num) { var col = db.getSiblingDB(dbName).getCollection(colName); for (i = 0; i < num; i++) { col.insert({x:i}); } print(col.count()); } shell>insertData("mydb","myTest",40)