Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7795817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:10:45+00:00 2026-06-01T23:10:45+00:00

My items store in MongoDB like this : {ProductName:XXXX, Catalogs : [ { 50008064

  • 0

My items store in MongoDB like this :

{"ProductName":"XXXX",
   "Catalogs" : [
    {
        "50008064" : "Apple"
    },
    {
        "50010566" : "Box"
    },
    {
        "50016422" : "Water"
    }
]}

Now I want query all the items belong to Catalog:50008064,how to?
(the catalog id “50008064” , catalog name “Apple”)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:10:46+00:00Added an answer on June 1, 2026 at 11:10 pm

    You cannot query this in an efficient manner and performance will decrease as your data grows. As such I would consider it a schema bug and you should refactor/migrate to the following model which does allow for indexing :

    {"ProductName":"XXXX",
       "Catalogs" : [
        {
            id : "50008064",
            value : "Apple"
        },
        {
            id : "50010566",
            value : "Box"
        },
        {
            id : "50016422",
            value : "Water"
        }
    ]}
    

    And then index :

    ensureIndex({'Catalogs.id':1})
    

    Again, I strongly suggest you change your schema as this is a potential performance bottleneck you cannot fix any other way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Now I can add items with store.newItem() . After adding it, it's placing it
I want to use Context.Items to store some info of a User Control like:
I have an application where users can store items. Now each type of account
I have a record store of items which have (name, quantity, owner, status) Now
I have a store with items retrieved from server. I would like to detect
I'm using mongodb to store image metadata and S3 urls. I would like to
Links to iTunes store items like apps, launched from from Safari on OS X,
I am using Nodejs , mongodb database. We can use $nin like this Model.find({
I need to store items of varying length in a circular queue in a
HttpContext.Current.Items is a store that has a life span of the HTTP request. I'd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.