You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
704 B

  1. "use strict";
  2. const Promise = require('bluebird'),
  3. _ = require('lodash');
  4. /**
  5. * Entry schema
  6. *
  7. * @type {<Mongoose.Schema>}
  8. */
  9. var entrySchema = Mongoose.Schema({
  10. _id: String,
  11. title: {
  12. type: String,
  13. required: true,
  14. minlength: 2
  15. },
  16. subtitle: {
  17. type: String,
  18. default: ''
  19. },
  20. parent: {
  21. type: String,
  22. default: ''
  23. },
  24. content: {
  25. type: String,
  26. default: ''
  27. }
  28. },
  29. {
  30. timestamps: {}
  31. });
  32. entrySchema.index({
  33. _id: 'text',
  34. title: 'text',
  35. subtitle: 'text',
  36. content: 'text'
  37. }, {
  38. weights: {
  39. _id: 3,
  40. title: 10,
  41. subtitle: 5,
  42. content: 1
  43. },
  44. name: 'EntriesTextIndex'
  45. });
  46. module.exports = Mongoose.model('Entry', entrySchema);