Download src/models/friend.ts from Collabos/chatapi: direct link, hf CLI and curl.
- Browser
- Download file 960 Bytes
-
https://huggingface.co/spaces/Collabos/chatapi/resolve/main/src/models/friend.ts
- Command line
-
hf download hf://spaces/Collabos/chatapi/src/models/friend.ts
-
curl -L -o friend.ts https://huggingface.co/spaces/Collabos/chatapi/resolve/main/src/models/friend.ts
960 Bytes
| 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<IFriendRequest>( | |
| { | |
| 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<IFriendRequest> = mongoose.model<IFriendRequest>( | |
| 'FriendRequest', | |
| FriendRequestSchema | |
| ); | |