/** History requirement - Document can have embedded sub-documents - Document can have referenced documents - Document can be referenced by documents - On save: * copy current version * */ import { Schema } from 'mongoose' const historySchema = new Schema({ author: [Schema.Types.ObjectId], created: Date, version: Number, tag: String, reference: [Schema.Types.ObjectId] }) const basicSchema = { name: { type: String, maxlength: 20, required: true }, tag: { type: String, maxlength: 10, required: true }, description: { type: String, maxlength: 200 } } export const collection = { ...basicSchema, __history: [historySchema] }