Skip to content

Commit

Permalink
Add comment, like, playlist, and tweet models
Browse files Browse the repository at this point in the history
  • Loading branch information
hiteshchoudhary committed Jan 6, 2024
1 parent 7c91a52 commit 0150103
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/models/comment.model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import mongoose, {Schema} from "mongoose";
import mongooseAggregatePaginate from "mongoose-aggregate-paginate-v2";

const commentSchema = new Schema(
{
content: {
type: String,
required: true
},
video: {
type: Schema.Types.ObjectId,
ref: "Video"
},
owner: {
type: Schema.Types.ObjectId,
ref: "User"
}
},
{
timestamps: true
}
)


commentSchema.plugin(mongooseAggregatePaginate)

export const Comment = mongoose.model("Comment", commentSchema)
24 changes: 24 additions & 0 deletions src/models/like.model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import mongoose, {Schema} from "mongoose";


const likeSchema = new Schema({
video: {
type: Schema.Types.ObjectId,
ref: "Video"
},
comment: {
type: Schema.Types.ObjectId,
ref: "Comment"
},
tweet: {
type: Schema.Types.ObjectId,
ref: "Tweet"
},
likedBy: {
type: Schema.Types.ObjectId,
ref: "User"
},

}, {timestamps: true})

export const Like = mongoose.model("Like", likeSchema)
26 changes: 26 additions & 0 deletions src/models/playlist.model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import mongoose, {Schema} from "mongoose";

const playlistSchema = new Schema({
name: {
type: String,
required: true
},
description: {
type: String,
required: true
},
videos: [
{
type: Schema.Types.ObjectId,
ref: "Video"
}
],
owner: {
type: Schema.Types.ObjectId,
ref: "User"
},
}, {timestamps: true})



export const Playlist = mongoose.model("Playlist", playlistSchema)
15 changes: 15 additions & 0 deletions src/models/tweet.model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import mongoose, {Schema} from "mongoose";

const tweetSchema = new Schema({
content: {
type: String,
required: true
},
owner: {
type: Schema.Types.ObjectId,
ref: "User"
}
}, {timestamps: true})


export const Tweet = mongoose.model("Tweet", tweetSchema)

0 comments on commit 0150103

Please sign in to comment.