I'm working on mongoose schema and trying to create an address object which includes enum for countries and cities, city's enum needs to be changed depending on selected country like code snippet below. How could I do that?
const mongoose = require('mongoose');
const questionSchema = new mongoose.Schema({
address: {
country:{
type: String,
enum:['USA', 'GB', 'CA', 'BR' ....]
},
city:{
type: String,
enum:[...cities[`${country}]]
}
}
})
const cities ={
USA :['New York', 'Los Angeles'...],
GB :['London', 'Manchester'...]
}