Currently I have two almost identical schemas:
var userSchema = mongoose.Schema({
email: {type: String, unique: true, required: true, validate: emailVal
The simplest way for extending mongoose schema
import { model, Schema } from 'mongoose';
const ParentSchema = new Schema({
fromParent: Boolean
});
const ChildSchema = new Schema({
...ParentSchema.obj,
fromChild: Boolean // new properties come up here
});
export const Child = model('Child', ChildSchema);