import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';

/**
  * GM用户组接口
*/
@index({ uid: 1 })
@index({ api: 1 })

export default class GMRecord extends BaseModel {

  @prop({ required: true })
  uid: number;

  @prop({ required: true })
  api: string;

  @prop({ required: true })
  body: string;
   
  @prop({ required: true })
  result: string;

  public static async createRecord(uid: number, api: string, body: string, result: string) {
    const r = await GMRecordModel.insertMany({uid, api, body, result});
    return r;
  }
  
}

export const GMRecordModel = getModelForClass(GMRecord);

export interface GMRecordType extends Pick<DocumentType<GMRecord>, keyof GMRecord>{};