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