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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:05:45+00:00 2026-06-05T05:05:45+00:00

I’m writing a small companies profile management system on NodeJS. I use MongoDB for

  • 0

I’m writing a small companies profile management system on NodeJS. I use MongoDB for data storage. I have collection “companies”, where every object is a single company. Cetainly, companies have several params, such as “name”, “e-mail”, “tel”. These all are single string fields. Here’s my current schema for “company”-object.

{
    "company_name": "ACME Ltd.",
    "company_email": "acmeltd@example.com",
    "company_tel": "+49374727384",
    "_id": {
        "$oid": "4fd115b6e94a7e2408000001"
    }
}

Here is my code to save current “company”-profiles:

app.post('/addcompany',function(req,res){
    db.collection("companies",function(err,collection){
        collection.insert( {
            "company_name":req.body.company_name,
            "company_email":req.body.company_email,
            "company_tel":req.body.company_tel
        });
    });
    res.redirect('/companies');
});

However, every company has several (different for every company) suppliers and I’d like to storage them in “company”-object. So, I think I should create inner object “suppliers” inside my “company”-object, and object “suppliers” has to have inner objects “supplier1”, “supplier2”, etc. Every “supplier1”-object should have 6 params such as “supplier_name”, “supplier_tel”, etc. So, my question is, which is the best way to storage supplies list in my “company”-object and how should I work with is from NodeJS?

Update: I’ve modified my code like this, and now it works!

app.post('/addcompany',function(req,res){
    db.collection("companies",function(err,collection){
        collection.insert( {
            "company_name":req.body.company_name,
            "company_email":req.body.company_email,
            "company_tel":req.body.company_tel,
            "company_suppliers" : [
                { "supplier_name" : "jane_test", "supplier_tel" : "123456_test", "comment" : "Good supplier_test" },
                { "supplier_name" : "jessy_test", "supplier_tel" : "654321_test", "comment" : "Bad supplier_test" }
              ]
        });
    });
    res.redirect('/companies');
});
  • 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-05T05:05:47+00:00Added an answer on June 5, 2026 at 5:05 am

    If you’re set on storing them inside the company object, I’d recommend using the data structure meant for that purpose: arrays.

    The discussion on MongoDB about schema design is prevalent to the decisions you are here making: http://www.mongodb.org/display/DOCS/Schema+Design In particular look at the “Embedding and Linking” section.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

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.