channel.js 1.1 KB

123456789101112131415161718192021222324
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  5. const { Secret } = require('naf-framework-mongoose/lib/model/schema');
  6. const Channel = {
  7. user_id: { type: String, required: false, maxLength: 200 }, // 创建人id
  8. title: { type: String, required: false, maxLength: 200 }, // 标题
  9. orgin: { type: String, required: false, maxLength: 200 }, // 来源
  10. type: { type: String, required: false, maxLength: 200 }, // 类别
  11. room_id: { type: String, required: false, maxLength: 200 }, // 房间id,服务生成,从2001开始
  12. passwd: { type: Secret, required: false, maxLength: 200, select: false }, // 密码,房间号
  13. desc: { type: String, maxLength: 1000 }, // 简介
  14. create_time: { type: String, required: false, maxLength: 200, default: moment().format('YYYY-MM-DD HH:ss') }, // 创建时间
  15. };
  16. const schema = new Schema(Channel, { toJSON: { virtuals: true } });
  17. schema.index({ id: 1 });
  18. schema.plugin(metaPlugin);
  19. module.exports = app => {
  20. const { mongoose } = app;
  21. return mongoose.model('channel', schema, 'channel');
  22. };