Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

115
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda