project.js 592 B

123456789101112131415161718
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  4. // 项目表
  5. const project = {
  6. name: { type: String, required: true }, // 项目名称
  7. desc: { type: String }, // 描述
  8. remark: { type: String },
  9. };
  10. const schema = new Schema(project, { toJSON: { virtuals: true } });
  11. schema.index({ id: 1 });
  12. schema.index({ name: 1 });
  13. schema.index({ 'meta.createdAt': 1 });
  14. schema.plugin(metaPlugin);
  15. module.exports = app => {
  16. const { mongoose } = app;
  17. return mongoose.model('Project', schema, 'project');
  18. };