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

161
Views
How to search up for an schemas array index inside a Mongoose model

I have the following document, where globalData is an array inside of my globalEventSchema.

{
  "globalData": [
    {
      "event": "event-a",
      "generatedId": "969046612024361060",
      "_id": "626a0d5553e6eb2f5e1ce714"
    },
       // More instances of the Schema
  ],
  "__v": 0
}

I want to search through my GlobalEvents and find the globalData array where the event matches my given string. How can I achieve that using mongoose?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The following will look in the globalData array for the specified event

router.get('/', async (req, res) => {
  const { event } = req.body;
  const globalEvent = await GlobalEvent.findOne({
    'globalData.event': event,
  });
  if (globalEvent) {
    res.json(globalEvent);
  } else {
    res.json({
      error: 'No global event found',
    });
  }
});
about 4 years ago · Juan Pablo Isaza 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!