forked from EvolutionAPI/evolution-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat.model.ts
More file actions
26 lines (21 loc) · 677 Bytes
/
chat.model.ts
File metadata and controls
26 lines (21 loc) · 677 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { Schema } from 'mongoose';
import { dbserver } from '../../libs/db.connect';
export class ChatRaw {
_id?: string;
id?: string;
owner: string;
lastMsgTimestamp?: number;
labels?: string[];
}
type ChatRawBoolean<T> = {
[P in keyof T]?: 0 | 1;
};
export type ChatRawSelect = ChatRawBoolean<ChatRaw>;
const chatSchema = new Schema<ChatRaw>({
_id: { type: String, _id: true },
id: { type: String, required: true, minlength: 1 },
owner: { type: String, required: true, minlength: 1 },
labels: { type: [String], default: [] },
});
export const ChatModel = dbserver?.model(ChatRaw.name, chatSchema, 'chats');
export type IChatModel = typeof ChatModel;