Estoy creando una solicitud de publicación que contendrá información diversa sobre cada rol. Por ejemplo, en esta prueba, 'Analista de datos'.
En este puesto, quiero tener bastantes fuentes de datos, incluidos aspectos como el salario, la educación y las habilidades. Sin embargo, estoy usando recargas para visualizarlo, lo que significa que aunque necesito una clave, por ejemplo, una maestría, también necesito un valor numérico asociado, como el siguiente:
const educationData = [ { degree: 'Masters', A: 120, }, { degree: 'Bachelor', A: 98, }, { degree: 'PhD', A: 86, }, { degree: 'Industry', A: 99, }, { degree: 'Associate', A: 85, } ];Me gustaría almacenar esto dentro de mi esquema creado:
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}, }, );Dentro de esto, me gustaría almacenar los 'datos educativos' en la base de datos. Feliz de ingresarlo manualmente por ahora. Solo quiero saber cómo estructurar mi esquema/datos en la solicitud del cartero.
Por ejemplo, Entrada en "educación", almacenada con "Masters:120", "Bachelor:98", "PhD:86", etc. -> dentro de la solicitud de publicación:
{ "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!] }¡Gracias!
Primero podría modificar su carga útil en el formato de esquema.
Carga útil
const educationData = [ { degree: 'Masters', A: 120, }, { degree: 'Bachelor', A: 98, }, { degree: 'PhD', A: 86, }, { degree: 'Industry', A: 99, }, { degree: 'Associate', A: 85, } ];Proceso
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}] });Después de esto guardado. ¿Es eso lo que quieres?