我试图使用close $ where来获取mongoDB文档,但该函数返回我数据库中的第一个文档:
scanCode: function (scannedcode) {
try {
let carItem = Cars.findOne({ $where: function () { return this.codeBarre == 'TOYOTA CAMRY MC/ 2007CHASSIS/ 509740' } });
console.log(carItem)
return carItem;
}
catch (e) {
console.log(e.message)
}
答案 0 :(得分:2)
<强> EDITED 强>
scanCode: function (scannedcode) {
try {
let carItem = Cars.findOne({ $where: "this.codeBarre == 'TOYOTA CAMRY MC/ 2007CHASSIS/ 509740'" });
console.log(carItem)
return carItem;
}
catch (e) {
console.log(e.message)
}