program.js 1.0 KB

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 节目表
  5. const program = {
  6. type: { type: String, required: false, zh: '节目类型' }, //
  7. name: { type: String, required: false, zh: '名称' }, //
  8. brief: { type: String, required: false, zh: '简介' }, //
  9. path: { type: String, required: false, zh: '视频流' }, //
  10. is_use: { type: String, required: false, zh: '是否启用', default: '0' }, //
  11. sort: { type: Number, required: false, zh: '排序', default: 1 }, //
  12. };
  13. const schema = new Schema(program, { toJSON: { getters: true, virtuals: true } });
  14. schema.index({ id: 1 });
  15. schema.index({ 'meta.createdAt': 1 });
  16. schema.index({ type: 1 });
  17. schema.index({ name: 1 });
  18. schema.index({ brief: 1 });
  19. schema.index({ path: 1 });
  20. schema.index({ is_use: 1 });
  21. schema.index({ sort: 1 });
  22. schema.plugin(metaPlugin);
  23. module.exports = app => {
  24. const { mongoose } = app;
  25. return mongoose.model('Program', schema, 'program');
  26. };