I have this structure:
{
personFullName: String,
personMobileOS: Number // 1 = IOS, 2 = Android,
moreDetails: Mixed
}
I want to add conditional schema based on other field like this:
if (personMobileOS === 1) { // IOS
moreDetails = {
iosVersion: Number,
loveApple: Boolean
}
} else if (personMobileOS === 2) { // Android
moreDetails = {
wantToSell: Boolean,
wantToSellPrice: Number
wantToSellCurrency: Number // 1 = Dollar, 2 = Euro, 3 = Pound
}
}
As you can see, the schema for "moreDetails" is conditional, it's possible to achieve this in mongoose?