Skip to content

Commit

Permalink
Model Creation Done
Browse files Browse the repository at this point in the history
  • Loading branch information
pronazmul committed Jun 11, 2021
1 parent e846855 commit 3dcbed4
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
31 changes: 31 additions & 0 deletions models/Conversation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// External Module:
const mongoose = require("mongoose");

// Make Conversation Schema:
const ConversationSchema = mongoose.Schema(
{
creator: {
id: mongoose.Types.ObjectId,
name: String,
avatar: String,
},
participant: {
id: mongoose.Types.ObjectId,
name: String,
avatar: String,
},
last_updated: {
type: Date,
default: Date.now,
},
},
{
timestamps: true,
}
);

// Make Convertation Model:
const Conversation = mongoose.model("Conversation", ConversationSchema);

// Model Export
module.exports = Conversation;
37 changes: 37 additions & 0 deletions models/Message.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// External Modules:
const mongoose = require("mongoose");

// Create Message Schema:
const MessageSchema = mongoose.Schema(
{
text: String,
attachment: [{ type: String }],
sender: {
id: mongoose.Types.ObjectId,
name: String,
avatar: String,
},
receiver: {
id: mongoose.Types.ObjectId,
name: String,
avatar: String,
},
date_time: {
type: Date,
defaul: Date.now,
},
conversation_id: {
type: mongoose.Types.ObjectId,
required: true,
},
},
{
timestamps: true,
}
);

// Create Message Model:
const Message = mongoose.model("Message", MessageSchema);

// Export Model:
module.exports = Message;

0 comments on commit 3dcbed4

Please sign in to comment.