I'm trying to get a mongoDB document using close $where but the function return the first document in my database:
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)
}
Cars.findOne({ codeBarre: 'TOYOTA CAMRY MC/ 2007CHASSIS/ 509740' });orCars.find({ codeBarre: 'TOYOTA CAMRY MC/ 2007CHASSIS/ 509740' }).fetch();