basicSchema.js 686 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /** History requirement
  2. - Document can have embedded sub-documents
  3. - Document can have referenced documents
  4. - Document can be referenced by documents
  5. - On save:
  6. * copy current version
  7. *
  8. */
  9. import { Schema } from 'mongoose'
  10. const historySchema = new Schema({
  11. author: [Schema.Types.ObjectId],
  12. created: Date,
  13. version: Number,
  14. tag: String,
  15. reference: [Schema.Types.ObjectId]
  16. })
  17. const basicSchema = {
  18. name: {
  19. type: String,
  20. maxlength: 20,
  21. required: true },
  22. tag: {
  23. type: String,
  24. maxlength: 10,
  25. required: true },
  26. description: {
  27. type: String,
  28. maxlength: 200 }
  29. }
  30. export const collection = {
  31. ...basicSchema,
  32. __history: [historySchema]
  33. }