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

109
Views
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
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!