Home > Net >  How to unselect a particular document in mongoose
How to unselect a particular document in mongoose

Time:09-22

here, i have access to userId and i want to get result without document of that perticular user. So, how can i do this in mongoose?

  async peopleyoumayknow(req, res){
    const {id} = req.params
    const response = await userModel.find({}).sort({creation_date:-1}).limit(12)
    return res.send(response)

  }

CodePudding user response:

Update your code to

async peopleyoumayknow(req, res){
    const {id} = req.params
    const response = await userModel.find({ _id: {"$ne": id}}).sort({creation_date:-1}).limit(12);
    return res.send(response)
  }
  • Related