You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
878 B
24 lines
878 B
// chat-message.js
|
|
// Copyright (C) 2024 DTP Technologies, LLC
|
|
// All Rights Reserved
|
|
|
|
'use strict';
|
|
|
|
import mongoose from 'mongoose';
|
|
const Schema = mongoose.Schema;
|
|
|
|
const CHANNEL_TYPE_LIST = ['ChatRoom'];
|
|
|
|
const ChatMessageSchema = new Schema({
|
|
created: { type: Date, default: Date.now, required: true, index: -1, expires: '30d' },
|
|
expires: { type: Date, index: -1 },
|
|
channelType: { type: String, enum: CHANNEL_TYPE_LIST, required: true },
|
|
channel: { type: Schema.ObjectId, required: true, index: 1, refPath: 'channelType' },
|
|
author: { type: Schema.ObjectId, required: true, index: 1, ref: 'User' },
|
|
content: { type: String },
|
|
mentions: { type: [Schema.ObjectId], select: false, ref: 'User' },
|
|
hashtags: { type: [String], select: false },
|
|
links: { type: [Schema.ObjectId], ref: 'Link' },
|
|
});
|
|
|
|
export default mongoose.model('ChatMessage', ChatMessageSchema);
|