File tree Expand file tree Collapse file tree 3 files changed +64
-10
lines changed Expand file tree Collapse file tree 3 files changed +64
-10
lines changed Original file line number Diff line number Diff line change 1+ const mongoose = require ( "mongoose" ) ;
2+
3+ const chatSchema = new mongoose . Schema ( {
4+ message : {
5+ type : String ,
6+ required : true ,
7+ } ,
8+ room : {
9+ type : mongoose . Schema . Types . ObjectId ,
10+ ref : "Room" ,
11+ required : true ,
12+ } ,
13+ sender : {
14+ type : mongoose . Schema . Types . ObjectId ,
15+ ref : "User" ,
16+ required : true ,
17+ } ,
18+ createdAt : {
19+ type : Date ,
20+ default : Date . now ,
21+ } ,
22+ } ) ;
23+
24+ module . exports = mongoose . model ( "Chat" , chatSchema ) ;
Original file line number Diff line number Diff line change 1+ const mongoose = require ( "mongoose" ) ;
2+
3+ const roomSchema = new mongoose . Schema ( {
4+ slug : {
5+ type : String ,
6+ unique : true ,
7+ required : true ,
8+ } ,
9+ name : {
10+ type : String ,
11+ required : true ,
12+ } ,
13+ admin : {
14+ type : mongoose . Schema . Types . ObjectId ,
15+ ref : "User" ,
16+ required : true ,
17+ } ,
18+ participants : [
19+ {
20+ type : mongoose . Schema . Types . ObjectId ,
21+ ref : "User" ,
22+ } ,
23+ ] ,
24+ chats : [
25+ {
26+ type : mongoose . Schema . Types . ObjectId ,
27+ ref : "Chat" ,
28+ } ,
29+ ] ,
30+ canvasData : {
31+ type : Object , //in json format
32+ default : { } ,
33+ } ,
34+ createdAt : {
35+ type : Date ,
36+ default : Date . now ,
37+ } ,
38+ } ) ;
39+
40+ module . exports = mongoose . model ( "Room" , roomSchema ) ;
You can’t perform that action at this time.
0 commit comments