team.js 1.0 KB

12345678910111213141516171819202122232425262728293031
  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 { ObjectId } = require('mongoose').Types;
  6. // 团队表
  7. const team = {
  8. name: { type: String }, // 团队名称
  9. create_user: { type: String }, // 团队创建人
  10. create_id: { type: String }, // 团队创建人id
  11. logo: { type: Array }, // 团队logo
  12. type: { type: String }, // 团队类型
  13. members: { type: Array }, // 团队成员
  14. create_time: { type: String }, // 创建时间
  15. status: { type: String, default: '0' }, // 团队状态
  16. remark: { type: String },
  17. };
  18. const schema = new Schema(team, { toJSON: { virtuals: true } });
  19. schema.index({ id: 1 });
  20. schema.index({ name: 1 });
  21. schema.index({ create_id: 1 });
  22. schema.index({ type: 1 });
  23. schema.index({ status: 1 });
  24. schema.index({ create_time: 1 });
  25. schema.index({ 'meta.createdAt': 1 });
  26. schema.plugin(metaPlugin);
  27. module.exports = app => {
  28. const { mongoose } = app;
  29. return mongoose.model('Team', schema, 'team');
  30. };