diff --git a/src/models/comment.model.js b/src/models/comment.model.js new file mode 100644 index 00000000..f6b16875 --- /dev/null +++ b/src/models/comment.model.js @@ -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) \ No newline at end of file diff --git a/src/models/like.model.js b/src/models/like.model.js new file mode 100644 index 00000000..963e127a --- /dev/null +++ b/src/models/like.model.js @@ -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) \ No newline at end of file diff --git a/src/models/playlist.model.js b/src/models/playlist.model.js new file mode 100644 index 00000000..8bb94eeb --- /dev/null +++ b/src/models/playlist.model.js @@ -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) \ No newline at end of file diff --git a/src/models/tweet.model.js b/src/models/tweet.model.js new file mode 100644 index 00000000..a3f7d1f6 --- /dev/null +++ b/src/models/tweet.model.js @@ -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) \ No newline at end of file