- 2018-07-27 查询键值
在shell中
//可以在toArray后面接着写数遍历方法
db.collection.find({},"key":value|修改器).toArray().forEach((item)=>{
print (item.key)
})
在node中使用驱动
//不可以在toArray后面写数组的遍历方法
db.collection("集合").find({},"key":value|修改器).toArray((err,item)=>{
item.forEach((detailItem)=>{
console.log(item.key);
})
})
//使用findOne查询数据,然后获得具体的数据
db.collection("集合").findOne({},"key":修改器,function(err,doc){
console.log(doc);
})
- 2018-07-27 在node.js中使用_id作为查询对象
var ObjectId = require('mongodb').ObjectID; //Does not work
var ObjectId = require('mongodb').ObjectId;//Work
- 2018-08-07 使用mongolass时报错
DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
// 解决连接
https://www.imooc.com/wenda/detail/394858