import mongoose, { Schema, Document, Model } from 'mongoose'; /** * FriendRequest model — tracks pending/accepted/rejected friend requests. * Used by REST-style HTTP upgrade calls (future) or future REST API layer. */ export interface IFriendRequest extends Document { fromUid: string; toUid: string; status: 'pending' | 'accepted' | 'rejected'; createdAt: Date; updatedAt: Date; } const FriendRequestSchema = new Schema( { fromUid: { type: String, required: true, index: true }, toUid: { type: String, required: true, index: true }, status: { type: String, enum: ['pending', 'accepted', 'rejected'], default: 'pending', }, }, { timestamps: true } ); // Prevent duplicate requests FriendRequestSchema.index({ fromUid: 1, toUid: 1 }, { unique: true }); export const FriendRequestModel: Model = mongoose.model( 'FriendRequest', FriendRequestSchema );