Hello it’s my first message here ! thanks for your help.
i am a newbie on mongo and i am unable to output a range of values on a find.
I am using the latest nodejs driver.
// node route
router.get('/sel', (req, res)=>{
async function selecDatas() {
const client = new MongoClient(uri, { useUnifiedTopology: true } )
try {
await client.connect( );
const database = client.db('training');
const collection = database.collection('emoncms');
collection.find({ _id : ObjectID('5fc38b2f2626be03a023df57')},
{ 'exams.notes' : { $lt : 3 }} ).toArray(function(err, docs) {
console.log("Found the following records");
console.log(docs[0].exams);
});
} catch(e) {
console.log(e)
}
};
selectDatas().catch(console.dir);
res.end()
});
// return all exams ... not only $lt3 ???
name: 'Json',
surname: 'Bourne',
exams: [
{ _id: [ObjectID], notes: 1 },
{ _id: [ObjectID], notes: 2 },
{ _id: [ObjectID], notes: 4 },
{ _id: [ObjectID], notes: 3 }
]
}