Files
yinxin630--fiora/packages/database/mongoose/models/friend.ts
T
2026-07-13 12:27:50 +08:00

34 lines
654 B
TypeScript

import { Schema, model, Document } from 'mongoose';
const FriendSchema = new Schema({
createTime: { type: Date, default: Date.now },
from: {
type: Schema.Types.ObjectId,
ref: 'User',
index: true,
},
to: {
type: Schema.Types.ObjectId,
ref: 'User',
},
});
export interface FriendDocument extends Document {
/** 源用户id */
from: string;
/** 目标用户id */
to: string;
/** 创建时间 */
createTime: Date;
}
/**
* Friend Model
* 好友信息
* 好友关系是单向的
*/
const Friend = model<FriendDocument>('Friend', FriendSchema);
export default Friend;