Getting a list of a specific data

Thank you, I already visited the documentation before but I’ll look into it again. Thanks for your efforts. If anyone else has a tip or idea, I’d be glad to hear them

I tried it like this, after reading through the documentation, but I’m not getting logged anything into my console. Any tips?

  const cursor = client.db.userdata.find(( { $expr: { $lt: [ "$stats.currentHP", "$stats.maxHP" ] } }, { _id: 0, id: 1 } ))
  await cursor.forEach(doc => console.log(

As a refresher, I’m trying to get every document where the “stats.currentHP” property is LESS than the “stats.maxHP” property and as a test, print their “id” (not _id) property to the console, but I’m getting nothing

Your syntax is wrong. It looks like you are using the mongo shell syntax rather than the node driver syntax.

In the documentation supplied by @Prasad_Saya, the syntax for find() is specified as
find( query , options )
but with the first and last parenthesis your projection is part of the query. In addition, for a projection, options object has to be { projection : { fields list } }. So to be correct for node driver as specified in the supplied documentation you should be using (untested)

find( { $expr: { $lt: [ "$stats.currentHP", "$stats.maxHP" ] } }, { projection : { _id: 0, id: 1 } })