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