Using "mongoose": "4.9.8", I want to define a type for consistency and reuse. I know the concept, but I'm a little stuck on the syntax, For instance, say my mongoose schema looks like this
const thingsSchema = new Schema({
thing: {
type: String
,required: false
}
,location: {
city: {
type: String
,required: false
}
,state: {
type: String
,required: false
}
,country: {
type: String
,required: false
}
}
});
what I really want to do is use "Location" model/type over again elsewhere, and have location not be required...like this:
const thingsSchema = new Schema({
thing: {
type: String
,required: false
}
,location: {
type: Location
,required: false
}
});
I think it's done something like this - but Im unsure.
const Location: {
city: {
type: String
,required: false
}
,state: {
type: String
,required: false
}
,country: {
type: String
,required: false
}
};