Chat.js 550 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
    room: {
Choi Ga Young's avatar
Choi Ga Young committed
7
        type: mongoose.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
14
        type: String,
        required: true,
    },
Choi Ga Young's avatar
Choi Ga Young committed
15
16
17
18
    message: {
        type: String,
        required: true
    },
19
20
21
22
    profileimg :{
        type: String,
        default: '3cd14b9bcb2007f324fcb82e0b566cce'
    }
Soo Hyun Kim's avatar
Soo Hyun Kim committed
23
24
25
26
}, {
    timestamps: true
})

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