basicSchema.js 747 B

123456789101112131415161718192021222324252627282930313233343536373839
  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, model } from 'mongoose'
  10. const historySchema = new Schema({
  11. author: [Schema.Types.ObjectId],
  12. created: Date,
  13. tag: String,
  14. reference: [Schema.Types.ObjectId],
  15. head: Boolean
  16. })
  17. export const History = model('History', historySchema)
  18. const basicSchema = {
  19. name: {
  20. type: String,
  21. maxlength: 20,
  22. required: true },
  23. tag: {
  24. type: String,
  25. maxlength: 10,
  26. required: true },
  27. description: {
  28. type: String,
  29. maxlength: 200 }
  30. }
  31. export const collection = {
  32. ...basicSchema,
  33. __history: [historySchema]
  34. }