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

/**
  * GM用户组接口
*/
@index({ roleId: 1, hisRoleId: 1 })

export default class FriendPresentLog extends BaseModel {

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

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

  @prop({ required: true, type: ItemReward, default: [] })
  items: ItemReward[];

  public static async createRecord(roleId: string, hisRoleId: string, items: ItemReward[]) {
    const r = await FriendPresentLogModel.insertMany({roleId, hisRoleId, items});
    return r;
  }
  
}

export const FriendPresentLogModel = getModelForClass(FriendPresentLog);

export interface FriendPresentLogType extends Pick<DocumentType<FriendPresentLog>, keyof FriendPresentLog>{};