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

  • SEARCH
  • Home
  • 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 7590093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:19:17+00:00 2026-05-30T20:19:17+00:00

I have the following generic schema to represent different types of information. var Record

  • 0

I have the following generic schema to represent different types of information.

var Record = new Schema (
{
   type: {type: String}, // any string (foo, bar, foobar)
   value: {type: String}, // any string value
   o_id: {type:String}
}
);

Some of the records based on this schema have:

  • type=”car”
  • value=”ferrari” or
  • value=”ford”

Some records have type “topspeed” with value “210” but they always share o_id (e.g. related “ferrari has this topspeed”). So if “ferrari has top speed 300”, then both records have same o_id.

How can I make query to find “ferrari with topspeed 300” when I don’t know o_id?

The only solution I found out is to select cars “ferrari” first and then with knowledge of all o_id for all “ferrari” use it to find topspeed.

In pseudocode:

Record.find({type:"car", value:"ferrari"}, function(err, docs)
{
   var condition = [];// create array of all found o_id;
   Record.find({type:"topspeed", value:"300"}...
}

I know that some merging or joining might not be possible, but what about some chaining these conditions to avoid recursion?

EDIT:
Better example:

  • Lets imagine I have a HTML document that contains DIV elements with certain id (o_id).

  • Now each div element can contain different type of microdata items (Car, Animal…).

  • Each microdata item has different properties (“topspeed”, “numberOfLegs”…) based on the type (Car has a topspeed, animal numberOfLegs)

  • Each property has some value (310 kph, 4 legs)

Now I’m saving these microdata items to the database but in a general way, agnostic of the type and values they contain since the user can define custom schemas from Car, to Animal, to pretty much anything). For that I defined the Record schema: type consists of “itemtype_propertyname” and value is value of the property.

I would eventually like to query “Give me o_id(s) of all DIV elements that contain item Ferrari and item Dog” at the same time.

The reason for this general approach is to allow anyone the ability to define custom schema and corresponding parser that stores the values.

But I will have only one search engine to find all different schemas and value combinations that will treat all possible schemas as a single definition.

  • 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-05-30T20:19:18+00:00Added an answer on May 30, 2026 at 8:19 pm

    I think it’d be far better to combine all records that share an o_id into a single record. E.g.:

    {
      _id: ObjectId(...),
      car: "ferarri",
      topspeed: 300
    }
    

    Then you won’t have this problem, and your schema will be more efficient both in speed and storage size. This is how MongoDB is intended to be used — heterogenous data can be stored in a single collection, because MongoDB is schemaless. If you continue with your current design, then no, there’s no way to avoid multiple round-trips to the database.

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

Sidebar

Related Questions

So i have the following generic list: var topTenSomething = new List<Something>(); Here is
Is there any name for the following DB table design: Basically we have generic
I want to do the following: facebook.Schema.stream_data data = api.stream.get(null, new List<string> { page_id
I have following code in Generic Handler of Asp.net: var students= Student.GetStudents(); var result
I have the following generic class: public class MessageProcesser<T> where T : Message Inside
I have the following generic repository: public class GenericRepository<TEntity> where TEntity : class {
I have the following function to remove generic data from a linked list in
I have the following code implementation of my generic singleton provider: public sealed class
I have the following method that is supposed to be a generic Save to
I have the following model structure: class Container(models.Model): pass class Generic(models.Model): name = models.CharacterField(unique=True)

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.