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