Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

236
Views
How to read all documents from collection in mongoose?

Seems to be a simple question, but I can't find the answer. There is a collection of posts, documents of which have a field rubric. How to read ALL documents from this collection in mongoose using Post.find ({rubric: value}, function), but keeping rubric. What value has to be for this to work?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

To find according if a field exists whatever value it has, you can use $exists in this way:

db.collection.find({
  "rubric": {
    "$exists": true
  }
})

Using mongoose is the same query. Something like this:

yourModel.find({
  "rubric": {
    "$exists": true
  }
})

Example here.

Also, to know about these world in mongo world you can check documentation every time you have an issue.

At the left of the page you see "Reference > Operators" and there are a lof of different operators you can use.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!