links.js 638 B

12345678910111213141516171819
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 热点资讯表
  5. const linksSchema = {
  6. name: { type: String, required: true, maxLength: 200 }, // 名称
  7. linkurl: { type: String, required: true, maxLength: 800 }, // 链接地址
  8. create_time: { type: String, required: true, maxLength: 200 }, // 发布时间
  9. };
  10. const schema = new Schema(linksSchema, { toJSON: { virtuals: true } });
  11. schema.index({ id: 1 });
  12. schema.plugin(metaPlugin);
  13. module.exports = app => {
  14. const { mongoose } = app;
  15. return mongoose.model('Links', schema, 'links');
  16. };