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

110
Vistas
How to specify schema parameters in an instance from another schemas string enum parameter

So I have no idea exactly what to title this. I have been messing around with express and mongoose and following the Mozilla Express tutorial series. I decided to adapt their example to my own idea. I planned to create a Call of Duty weapon build database. One of my schemas would look something like this:

var GunSchema = new Schema({
  title: {type: String, required: true, maxLength: 100},
  weaponClass: { type: Schema.ObjectId, ref: 'weaponClass', required: true },
  optic: {type: String, enum: ['optic1','optic2','optic3']},
  magazine: {type: String, enum: ['mag1','mag2','mag3']},
  grip: {type: String, enum: ['grip1','grip2','grip3']},
  // etc etc
});

That would be for a gun which would be part of a weapon class (another schema) eg. AR, Sniper etc.

I want to know if it is possible to narrow it down based on a specific instance, for example, an AK47 based on this gun schema might only be able to equip optic1 and optic2, magazine1 and 3 etc. Am I going the right direction by including ALL of the possible attachments in the gun schema and trying to narrow it down from there or is there another path I should be taking?

Thanks in advance and any help is appreciated!

about 4 years ago · Juan Pablo Isaza
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