link.js 635 B

1234567891011121314151617181920
  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: false, maxLength: 200 }, // 图片路径
  9. };
  10. const schema = new Schema(LinkSchema, { toJSON: { virtuals: true } });
  11. schema.index({ id: 1 });
  12. schema.plugin(metaPlugin);
  13. module.exports = app => {
  14. const { mongoose } = app;
  15. return mongoose.model('Link', schema, 'link');
  16. };