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

173
Views
Mongoose find in array of object within object

Below is my mongpdb json document

{
        categoryId: '1',
        categoryName: 'Outdoors Equipments',
        items: [
            {
                itemId: '1',
                itemName: 'Camping Tent',
                itemDescription: 'A tent is a shelter consisting of sheets of fabric or other material draped over, attached to a frame of poles or attached to a supporting rope. While smaller tents may be free-standing or attached to the ground, large tents are usually anchored using guy ropes tied to stakes or tent pegs. First used as portable homes by nomads, tents are now more often used for recreational camping and as temporary shelters.',
                itemImage: '/images/camping-tent.jpeg',
                createdAt: DateTime.now().toLocaleString(DateTime.DATETIME_SHORT)
            },
            {
                itemId: '2',
                itemName: 'Camping Chair',
                itemDescription: 'A tent is a shelter consisting of sheets of fabric or other material draped over, attached to a frame of poles or attached to a supporting rope. While smaller tents may be free-standing or attached to the ground, large tents are usually anchored using guy ropes tied to stakes or tent pegs. First used as portable homes by nomads, tents are now more often used for recreational camping and as temporary shelters.',
                itemImage: '/images/camping-chair.jpeg',
                createdAt: DateTime.now().toLocaleString(DateTime.DATETIME_SHORT)
            },
            {
                itemId: '3',
                itemName: 'Camping Table',
                itemDescription: 'A tent is a shelter consisting of sheets of fabric or other material draped over, attached to a frame of poles or attached to a supporting rope. While smaller tents may be free-standing or attached to the ground, large tents are usually anchored using guy ropes tied to stakes or tent pegs. First used as portable homes by nomads, tents are now more often used for recreational camping and as temporary shelters.',
                itemImage: '/images/camping-table.jpeg',
                createdAt: DateTime.now().toLocaleString(DateTime.DATETIME_SHORT)
            },
        ]
    }

How do I search based on category and itemid and return json with category data and item data of that particular item using mongoose and nodejs express

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

0

You can use $elemMatch and $ operator for this $elemMatch document $ operator document

here is a working example https://mongoplayground.net/p/GxWp1MIcTcB

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!