user-relation.js 734 B

1234567891011121314151617181920
  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. // 绩效:用户关系表-关系表,只用model就行
  7. const userRelation = {
  8. user_id: { type: String }, // 用户id
  9. superior_id: { type: String }, // 上级id
  10. remark: { type: String },
  11. };
  12. const schema = new Schema(userRelation, { toJSON: { virtuals: true } });
  13. schema.index({ id: 1 });
  14. schema.index({ superior_id: 1 });
  15. schema.index({ 'meta.createdAt': 1 });
  16. schema.plugin(metaPlugin);
  17. module.exports = app => {
  18. const { mongoose } = app;
  19. return mongoose.model('UserRelation', schema, 'userRelation');
  20. };