/** 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, model } from 'mongoose' const historySchema = new Schema({ author: [Schema.Types.ObjectId], created: Date, tag: String, reference: [Schema.Types.ObjectId], head: Boolean }) export const History = model('History', historySchema) 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] }