I am developing an app using the MEAN stack, and I would like to create a schema as follows:
var UserSchema = new mongoose.Schema({
name: String,
active: {type: Boolean, default: true},
services : [{type: mongoose.Schema.Types.ObjectId}]
});
mongoose.model('User', UserSchema);
I would like the services to be of different types, with some functions that are present in all of them, so that I can iterate through them and call a function such as service.getStatus();
.
Is it possible to automatically populate the services array using Mongoose's populate()
function?
Thank you in advance for the help.
type
?