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 },
- 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');
- };
|