Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

111
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda