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.

53 lines
727 B

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