link.js 703 B

123456789101112131415161718192021
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 友情链接表
  5. const LinkSchema = {
  6. name: { type: String, required: false, maxLength: 200 }, // 链接名称
  7. url: { type: String, required: true, maxLength: 200 }, // 链接地址
  8. img_url: { type: String, required: true, maxLength: 200 }, // 图片路径
  9. sort: { type: String, required: false, maxLength: 200 }, // 排序
  10. };
  11. const schema = new Schema(LinkSchema, { toJSON: { virtuals: true } });
  12. schema.index({ id: 1 });
  13. schema.plugin(metaPlugin);
  14. module.exports = app => {
  15. const { mongoose } = app;
  16. return mongoose.model('Link', schema, 'link');
  17. };