I have the following scheme:
var user = Schema({
id: Number,
name: String,
surname: String,
role: { type: Schema.Types.ObjectId, ref: "" }//member or crew
property: Number
});
var member = Schema({
cod_id: Number,
aa: String,
bb: String,
});
var crew = Schema({
cod_id: Number,
cc: String,
dd: String,
});
Member and crew, they are both users but they have different attributes.
The only attributes that are equal are: name, surname, role and property.
What I would like to understand if it were possible to do such a thing, specifying in user the role attribute that can be either member or crew, refer to the specific model in question.
Everything stems from the need to have the property attribute in a single model and not having to put this attribute in either member or crew, otherwise when I have to do a search I have to do two, one in the model member and one in the crew, waiting for don't have duplicate problems.
Can you give me some advice?