1234567891011121314151617181920212223242526272829 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- // 节目表
- const program = {
- type: { type: String, required: false, zh: '节目类型' }, //
- name: { type: String, required: false, zh: '名称' }, //
- brief: { type: String, required: false, zh: '简介' }, //
- path: { type: String, required: false, zh: '视频流' }, //
- is_use: { type: String, required: false, zh: '是否启用', default: '0' }, //
- sort: { type: Number, required: false, zh: '排序', default: 1 }, //
- };
- const schema = new Schema(program, { toJSON: { getters: true, virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ type: 1 });
- schema.index({ name: 1 });
- schema.index({ brief: 1 });
- schema.index({ path: 1 });
- schema.index({ is_use: 1 });
- schema.index({ sort: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Program', schema, 'program');
- };
|