此查询未按预期工作:
Model.find().select('_id').lean().exec(function(err, ids) {
(...)
})
据我所知,lean() 方法应该将查询结果返回为 js 对象,而不是 mongodb bson。
edit:
实际结果:
forEach(function(item, index, array) {
console.log(item);
}
this:
_bsontype=ObjectID, 0=88, 1=198, 2=150, 3=109, 4=7, 5=81, 6=146, 7=44, 8=18, 9=94, 10=112, 11=159
_bsontype=ObjectID, 0=88, 1=198, 2=184, 3=185, 4=19, 5=120, 6=81, 7=12, 8=197, 9=73, 10=143, 11=217
_bsontype=ObjectID, 0=88, 1=198, 2=187, 3=53, 4=144, 5=27, 6=216, 7=20, 8=202, 9=80, 10=181, 11=183
_bsontype=ObjectID, 0=88, 1=198, 2=189, 3=10, 4=61, 5=115, 6=116, 7=28, 8=202, 9=233, 10=198, 11=106
预期成绩:
[{_id: "myid1"}, {_id: "myid2"}, {_id: "myid3"}, {_id: "myid4"}]