Chat.js 418 Bytes
Newer Older
Soo Hyun Kim's avatar
Soo Hyun Kim committed
1
2
import mongoose from 'mongoose'

Choi Ga Young's avatar
aa    
Choi Ga Young committed
3
const { String } = mongoose.Schema.Types
Soo Hyun Kim's avatar
Soo Hyun Kim committed
4
5

const ChatSchema = new mongoose.Schema({
Choi Ga Young's avatar
aa    
Choi Ga Young committed
6
7
    room: {
        type: ObjectId,
Soo Hyun Kim's avatar
Soo Hyun Kim committed
8
        required: true,
Choi Ga Young's avatar
aa    
Choi Ga Young committed
9
        ref: 'Room',
Soo Hyun Kim's avatar
Soo Hyun Kim committed
10
    },
Choi Ga Young's avatar
aa    
Choi Ga Young committed
11
    username: {
Soo Hyun Kim's avatar
Soo Hyun Kim committed
12
13
        type: String,
        required: true,
Choi Ga Young's avatar
aa    
Choi Ga Young committed
14
        ref: 'User',
Soo Hyun Kim's avatar
Soo Hyun Kim committed
15
    },
Choi Ga Young's avatar
aa    
Choi Ga Young committed
16
    message: String,
Soo Hyun Kim's avatar
Soo Hyun Kim committed
17
18
19
20
}, {
    timestamps: true
})

우지원's avatar
수정    
우지원 committed
21
export default mongoose.models.Chat || mongoose.model('Chat', ChatSchema)