'use strict'; const Schema = require('mongoose').Schema; const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); // 友情链接表 const LinkSchema = { name: { type: String, required: false, maxLength: 200 }, // 链接名称 url: { type: String, required: true, maxLength: 200 }, // 链接地址 img_url: { type: String, required: true, maxLength: 200 }, // 图片路径 sort: { type: String, required: false, maxLength: 200 }, // 排序 }; const schema = new Schema(LinkSchema, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Link', schema, 'link'); };