Home > Back-end >  MongoDB findOne but exclude some field - not working
MongoDB findOne but exclude some field - not working

Time:06-19

I'm new to MongoDB

I tried the findOne function, but it does not work the way I want it

client.db("game").collection("players").findOne({ _id: "s1" }, { data: 1, _id: 0 })

I want it to return only the data field without the _id

but it returns:

{
  _id: 's1',
  data: [somedata...]
}

My data is look like this (From MongoDB Compass):

enter image description here

CodePudding user response:

In MongoDB Version 5.0.6 the MongoDB query is working fine Output Of The Query

  • Related