1234567891011121314151617181920212223 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 上传资料表
- const MaterialSchema = {
- title: { type: String, required: true, maxLength: 200 }, // 标题
- url: { type: String, required: true, maxLength: 200 }, // 资料链接
- type: { type: String, required: true, maxLength: 200 }, // 资料类型,0-学生学习资料,1-教师学习资料
- content: { type: String, required: false, maxLength: 2000 }, // 简介
- tags: [ String ], // 标签
- score: { type: String, required: false, maxLength: 200 }, // 资料得分
- };
- const schema = new Schema(MaterialSchema, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Material', schema, 'material');
- };
|