I want to skip one user particular by using _id
and display all others users, I am trying below code its not working:
db.user.find(
{ _id: { $nin: ["5848e9ecaec0f31372816a26"] } },
{ username: 1 }
).pretty()
Use ObjectId for _id :
db.user.find( { _id: { $nin: [ObjectId("5848e9ecaec0f31372816a26")] } } )
Short answer: Use $ne
for one user db.user.find( {_id:{$ne:"5848e9ecaec0f31372816a26"} })
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With