basicSchema.js 765 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 mongoose from 'mongoose'
  10. export const historySchema = new mongoose.Schema({
  11. author: { type: String, required: true },
  12. created: Date,
  13. version: String,
  14. reference: [mongoose.Schema.Types.ObjectId],
  15. head: { type: Boolean, required: true },
  16. comment: String
  17. })
  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. }