column.js 853 B

1234567891011121314151617181920212223
  1. "use strict";
  2. const Schema = require("mongoose").Schema;
  3. const moment = require("moment");
  4. const metaPlugin = require("naf-framework-mongoose-free/lib/model/meta-plugin");
  5. const { Secret } = require("naf-framework-mongoose-free/lib/model/schema");
  6. // 栏目表
  7. const column = {
  8. name: { type: String, required: true }, // 栏目名称
  9. site: { type: String, required: false }, // 栏目位置
  10. brief: { type: String, required: false }, // 简介
  11. remark: { type: String, maxLength: 200 },
  12. create_time: { type: String },
  13. };
  14. const schema = new Schema(column, { toJSON: { virtuals: true } });
  15. schema.index({ id: 1 });
  16. schema.index({ name: 1 });
  17. schema.index({ site: 1 });
  18. schema.index({ "meta.createdAt": 1 });
  19. schema.plugin(metaPlugin);
  20. module.exports = (app) => {
  21. const { mongoose } = app;
  22. return mongoose.model("Column", schema, "column");
  23. };