const Schema = require('mongoose').Schema;


let userRoleSchema = new Schema({
  time: { type: Date, default: Date.now, desc: '授权时间', },
  authorizer: { type: Schema.Types.ObjectId, ref: 'User', desc: '授权者', },
  user: { type: Schema.Types.ObjectId, ref: 'User', desc: '用户', required: true, },
  role: { type: Schema.Types.ObjectId, ref: 'Role', desc: '角色', required: true, },
}, {
  toJSON: {}
});

userRoleSchema.index({
  user: 1,
  role: 1,
  dealer: 1
}, {
  unique: true
});



module.exports = userRoleSchema
