12345678910111213141516171819202122232425262728293031 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- const { ObjectId } = require('mongoose').Types;
- // 团队表
- const team = {
- name: { type: String }, // 团队名称
- create_user: { type: String }, // 团队创建人
- create_id: { type: String }, // 团队创建人id
- logo: { type: Array }, // 团队logo
- type: { type: String }, // 团队类型
- members: { type: Array }, // 团队成员
- create_time: { type: String }, // 创建时间
- status: { type: String, default: '0' }, // 团队状态
- remark: { type: String },
- };
- const schema = new Schema(team, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ name: 1 });
- schema.index({ create_id: 1 });
- schema.index({ type: 1 });
- schema.index({ status: 1 });
- schema.index({ create_time: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Team', schema, 'team');
- };
|