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 8147699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:26:08+00:00 2026-06-06T14:26:08+00:00

So I have a schema with people and groups. I want to make it

  • 0

So I have a schema with people and groups. I want to make it possible for a person to be related to one or more people or groups. So far I have this:

var PersonSchema = new Schema({
    name    : String,
});
var PersonModel = mongoose.model('Person', PersonSchema);

var GroupSchema = new Schema({
    name    : String,
    members : [PersonSchema]
});
var GroupModel = mongoose.model('Group', GroupSchema);

How to add to PersonSchema a set of one or more groups and/or other people?

  • 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-06T14:26:09+00:00Added an answer on June 6, 2026 at 2:26 pm

    Assuming you have both Persons and Groups collections in your database based on this, you could add arrays of ObjectId refs to PersonSchema to capture a person’s relationships with other people or groups. As in:

    var PersonSchema = new Schema({
        name    : String,
        people: [{ type: Schema.ObjectId, ref: 'Person' }],
        groups: [{ type: Schema.ObjectId, ref: 'Group' }]
    });
    

    Then you can use mongoose’s populate support to follow those refs whenever you need their full details.

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

Sidebar

Related Questions

I have a table which have schema like this id name 1 jack 2
i have this schema: <div id=container> <div id=content>some text</div> <footer> my footer things </footer>
I have a schema design that looks like this: Table: User Row Column Family
I have a schema like this <h1> 5/2009 <br/> Question: This is the question
I have this schema: <xs:complexType name=foo> <xs:sequence> <xs:element name=oneBar type=xs:string minOccurs=0/> <xs:element name=twoBar type=xs:string
I have people inserting video code to be displayed on my website. I want
I have a DB where i keep data of people who make loans. Loans
I have a MySQL database called People which contains the following schema <id,name,foodchoice1,foodchoice2> .
I have a question about a database schema for a certain website where people
Ok, suppose to have this db schema (relation): |User | (1-->n) |Customer | (1-->n)

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.