import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { HydratedDocument, Types } from 'mongoose';

export type PostPreferenceDocument = HydratedDocument<PostPreference>;

@Schema({ timestamps: true, versionKey: false })
export class PostPreference {
  @Prop({ type: Types.ObjectId, required: true, index: true })
  userId!: Types.ObjectId;

  @Prop({ type: Types.ObjectId, required: true, index: true })
  postId!: Types.ObjectId;

  @Prop({ default: true })
  notInterested!: boolean;
}

export const PostPreferenceSchema = SchemaFactory.createForClass(PostPreference);
PostPreferenceSchema.index({ userId: 1, postId: 1 }, { unique: true });
