---
title: "Comment by Pratik Zinjurde on \"#100DaysOfMERN - Day 50\" | Hashnode"
description: "hi can you tell me why this code is not working let user=await User.find({ _id: { $ne: userid } }, {friendsList : {$ne:userid}}).limit(3) im getting this error"
url: "https://hashnode.com/posts/100daysofmern-day-50/6059dd1b25962412b9818ad6/comment/605c6e1078c4742436d50f17"
---

[Discussion](https://hashnode.com/posts/100daysofmern-day-50/6059dd1b25962412b9818ad6)

Comment [#100DaysOfMERN - Day 50](https://hashnode.com/posts/100daysofmern-day-50/6059dd1b25962412b9818ad6)

[Pratik Zinjurde](https://hashnode.com/@pratikpz)

[Mar 25, 2021](https://hashnode.com/posts/100daysofmern-day-50/6059dd1b25962412b9818ad6/comment/605c6e1078c4742436d50f17)

hi can you tell me why this code is not working let user=await User.find({ \_id: { $ne: userid } }, {friendsList : {$ne:userid}}).limit(3) im getting this error in postman { "ok": 0, "code": 2, "codeName": "BadValue", "name": "MongoError" }

[marayana](https://hashnode.com/@marayana)

[Mar 25, 2021](https://hashnode.com/posts/100daysofmern-day-50/6059dd1b25962412b9818ad6/comment/605c6e1078c4742436d50f17#reply-605cc0967732a34112e75757)

I'm a little confused about what you're trying to achieve with that query.

The first object passed to .find specifies some search criteria, so you're fetching all users except the one with \_id === userid.

The second object specifies which fields to include in the output, equivalent to a $project stage. You're creating a new field "friendsList", and pass in an expression {$ne:userid}.

First thing is, you'd have to pass an array to $ne, specifying which values to compare, something like: { $ne: \[ '$friendsList.\_id', userid \] }

However, I'm not sure if that'll do what you expect, because that will return documents with a "friendsList" field and a Boolean as value.

Generally, I don't think it's possible to filter with $project. Assuming that you _do_ want to filter, put it into the first object. Maybe you're looking for something like this? User.find( { \_id: { $ne: userid }, friendsList: { $ne: userid } } )

That would return a list of users where

-   \_id !== userid (-> all users except one)
-   userid is not present in the friendsList

So basically a list of people who aren't friends with Mr. Userid.

Hope that answered your question.
