数据删除
db.集合.remove(删除条件,是否只删除一个数据);
默认删多条(false)true删除一条db.集合.remove({}) 删除所有元素但集合还在db.集合.drop() 删除集合游标
指数据可以一行行的进行操作,类似ResultSet数据处理在mongo里是需要使用find()就可以返回游标了对于操作返回的游标,可使用函数操作1.判断是否有下一行数据:hasNext()2.取当前数据: next()var cur=db.web.find();
cur.hasNext();cur.next();![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
> db.web.find();{ "_id" : ObjectId("592c945f997b7830e7f76d05"), "lan" : "php7", "need" : [ "mysql", "js", "html", "css", "tp", "yii" ] }{ "_id" : ObjectId("592c945f997b7830e7f76d06"), "lan" : "jav a", "need" : [ "mysql", "js", "html", "css", "oracle", "spring" ] }{ "_id" : ObjectId("592c945f997b7830e7f76d07"), "lan" : "python", "need" : [ "mysql", "js", "html", "css", "flask" ] }{ "_id" : ObjectId("592c945f997b7830e7f76d08"), "lan" : "PythoN", "need" : [ "mysql", "js", "html", "css", "flask", "diagno" ] }> var cur=db.web.find();> cur.hasNext();true> cur.next();{ "_id" : ObjectId("592c945f997b7830e7f76d05"), "lan" : "php7", "need" : [ "mysql", "js", "html", "css", "tp", "yii" ]}var cur=db.web.find();while(cur.hasNext()){ var p=cur.next(); print(p.lan);}> var cur=db.web.find();> while(cur.hasNext()){... var p=cur.next();... print(p.lan);... }php7jav apythonPythoN
p是object
如果需要输出json可使用printjson()> var cur=db.web.find();> while(cur.hasNext()){... var p=cur.next();... print(p);... }[object BSON][object BSON][object BSON][object BSON]var cur=db.web.find();while(cur.hasNext()){ var p=cur.next(); printjson(p);}