Almost too obvious, but here is what I finally came up with:
Define the reusable parts separately, however, contrary to my first thoughts: do not use Schema here:
var addressSubschema = { street: String, number: String, zip: String, city: String }
Just include this part in real schemes:
var personSchema = new mongoose.Schema({ name: { type: String, required: true }, title: { type: String }, address: addressSubschema }); var companySchema = new mongoose.Schema({ name: { type: String, required: true }, addresses: [addressSubschema] });
qqilihq
source share