聊天:加入大部分聊天所需数据库表

This commit is contained in:
liangtongchuan
2021-02-28 21:28:09 +08:00
parent e80818e660
commit e80ef881be
4 changed files with 155 additions and 0 deletions

34
shared/db/ChatInfo.ts Normal file
View File

@@ -0,0 +1,34 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
/**
* 记录聊天信息,包含配置、最近聊天等
**/
@modelOptions({ schemaOptions: { id: false } })
@index({ roleId: 1 })
export default class ChatInfo extends BaseModel {
@prop({ required: true, default: '' })
roleId: string; // 消息发送者 roleId
@prop({ required: true, default: '' })
roleName: string; // 消息发送者名称
@prop({ required: true, type: String, default: [] })
sources: [string]; // 打开的消息来源,主要用于系统通知筛选
@prop({ required: true, type: String, default: [] })
BSChannels: [string]; // 弹幕打开的频道BSbullet screen
@prop({ required: true, type: String, default: [] })
BSSources: [string]; // 弹幕打开的消息来源
@prop({ required: true, default: '' })
bubbleId: string; // 气泡编号
@prop({ required: true, type: String, default: [] })
recentPrivateChats: [{ // 最近聊天列表
targetRoleId: string; // 聊天玩家 roleId
roomId: string; // 聊天 Id
lastReadTime: Date; // 最后查看时间
}];
}
export const ChatInfoModel = getModelForClass(ChatInfo);
export interface ChatInfoType extends Pick<DocumentType<ChatInfo>, keyof ChatInfo> {};