import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { HydratedDocument, Types } from 'mongoose';
import { User } from '../../users/schemas/user.schema';

export type ChatBlockDocument = HydratedDocument<ChatBlock>;

@Schema({ timestamps: true, versionKey: false })
export class ChatBlock {
  @Prop({ type: Types.ObjectId, ref: User.name, required: true, index: true })
  blockerId!: Types.ObjectId;

  @Prop({ type: Types.ObjectId, ref: User.name, required: true, index: true })
  blockedId!: Types.ObjectId;
}

export const ChatBlockSchema = SchemaFactory.createForClass(ChatBlock);
ChatBlockSchema.index({ blockerId: 1, blockedId: 1 }, { unique: true });
