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-room.js
|
|
// Copyright (C) 2024 DTP Technologies, LLC
|
|
// All Rights Reserved
|
|
|
|
'use strict';
|
|
|
|
import { MIN_ROOM_CAPACITY, MAX_ROOM_CAPACITY } from './lib/constants.js';
|
|
|
|
import mongoose from 'mongoose';
|
|
const Schema = mongoose.Schema;
|
|
|
|
const ChatRoomSchema = new Schema({
|
|
created: { type: Date, default: Date.now, required: true, index: 1, expires: '7d' },
|
|
owner: { type: Schema.ObjectId, required: true, index: 1, ref: 'User' },
|
|
name: { type: String, required: true },
|
|
topic: { type: String },
|
|
capacity: { type: Number, required: true, min: MIN_ROOM_CAPACITY, max: MAX_ROOM_CAPACITY },
|
|
accessToken: { type: String, required: true },
|
|
invites: { type: [Schema.ObjectId], select: false },
|
|
members: { type: [Schema.ObjectId], select: false },
|
|
banned: { type: [Schema.ObjectId], select: false },
|
|
});
|
|
|
|
export default mongoose.model('ChatRoom', ChatRoomSchema);
|