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

111
Views
Storing an Array of String to a Key in MongoDB

I'm building a post request which will contain various info on each role. E.g in this trial, 'Data Analyst'.

In this position I want to have quite a few sources of data, including things like salary, education and skills. However, I'm using recharts to visualise it, which means although I need a key, e.g Masters's degree, I also need a num value associated, such as below:

const educationData = [
  {
    degree: 'Masters',
    A: 120,

  },
  {
    degree: 'Bachelor',
    A: 98,
  },
  {
    degree: 'PhD',
    A: 86,
  },
  {
    degree: 'Industry',
    A: 99,
  },
  {
    degree: 'Associate',
    A: 85,
  }
];

I would like to store this inside my schema created:

const RolesPositionSchema = new mongoose.Schema(
    {
        title:{type:String, required: true, unique: true},
        desc:{type:String, required: true},
        skills:{type:Array, required: true},
        salary:{type:Array}, 
        education: {type: Array},
        popularity: {type: Number},
        reccomendations: {type: Array},
    },
);

Within this I would like to store the 'educationData' into the DB. Happy to input it in manually for now. I just want to know how to structure my schema/data in the postman request.

E.g Input in "education", stored with "Masters:120", "Bachelor:98", "PhD:86" etc -> within the post request:

{
    "title" : "Data Analyst",
    "desc": "Using both internal and external data sources you will develop insights to identify trends and opportunities whilst highlighting areas or improvement to optimise member interaction. This is a proactive role where you will own how we interpret data, allowing you to   provide valuable insight into the development and implementation of product, customer and channel strategies for our sales, retention, and acquisition goals.",
    "skills":["SQL" ,"Excel", "Tableau", "PowerBI", "Python", "Azure", "AWS", "ETL"],
    "education": ["INPUT AN ARRAY OF EDUCATION AND THEIR VALUES HERE!]
}

Thankyou!

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

0

You could modify first your payload into the format of schema.

Payload

const educationData = [
  {
    degree: 'Masters',
    A: 120,
  },
  {
    degree: 'Bachelor',
    A: 98,
  },
  {
    degree: 'PhD',
    A: 86,
  },
  {
    degree: 'Industry',
    A: 99,
  },
  {
    degree: 'Associate',
    A: 85,
  }
];

Process

const newEducations = educationData.map(education => {
    return `${education.degree}:${education.A}`;
});

const storeRole = new RolesPositionSchema({
    title: 'Data Analyst',
    desc: 'Using both internal and external data sources you will develop insights to identify trends and opportunities whilst highlighting areas or improvement to optimise member interaction. This is a proactive role where you will own how we interpret data, allowing you to   provide valuable insight into the development and implementation of product, customer and channel strategies for our sales, retention, and acquisition goals.',
    skills: [{Skill value}],
    salary: [{Salary value}],
    education: newEducations,
    popularity: 0,
    reccomendations: [{Recommendation value}]
});

After this saved. Does it that you want?

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!