DEV Community

Cover image for Filter only one field in mongodb
Dezina
Dezina

Posted on

Filter only one field in mongodb

const jobData = await JobRequirement.find({cId: user.corporateId}, {_id: 1})

      console.log("result", jobData)
Enter fullscreen mode Exit fullscreen mode
result [
  { _id: 61d3e5dc0b2613ae328cc0c5 },
  { _id: 61d3e66e0b2613ae328cc0c6 },
  { _id: 61d3e74a0b2613ae328cc0c7 },
  { _id: 61d556dc0b2613ae328cc169 },
  { _id: 61d57dc20b2613ae328cc16a },
  { _id: 61d580900b2613ae328cc16c },
  { _id: 61d59a9d0b2613ae328cc16d },
  { _id: 61d84bd90b2613ae328cc18f },
  { _id: 61d84c700b2613ae328cc190 },
  { _id: 61d92c710b2613ae328cc1ac },
  { _id: 61d92ecd0b2613ae328cc1ad },
  { _id: 61d947510b2613ae328cc1ae },
  { _id: 61d996ef0595f55e1f4e0a40 }
]

Top comments (0)