Skip to content

Commit 3c7ba21

Browse files
committed
add comment, tweet, playList, like models
1 parent cff6332 commit 3c7ba21

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

src/models/comment.model.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import mongoose, { Schema } from "mongoose";
2+
import mongooseAggregatePaginate from "mongoose-aggregate-paginate-v2";
3+
4+
const commentSchema = new Schema(
5+
{
6+
content: { type: String, required: true },
7+
owner: { type: Schema.Types.ObjectId, ref: "User", required: true },
8+
video: { type: Schema.Types.ObjectId, ref: "Video", required: true },
9+
likes: [{ type: Schema.Types.ObjectId, ref: "User" }],
10+
dislikes: [{ type: Schema.Types.ObjectId, ref: "User" }],
11+
replies: [{ type: Schema.Types.ObjectId, ref: "Comment" }],
12+
},
13+
{ timestamps: true }
14+
);
15+
16+
commentSchema.plugin(mongooseAggregatePaginate);
17+
export const Comment = mongoose.model("Comment", commentSchema);

src/models/like.model.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import mongoose, { Schema } from "mongoose";
2+
3+
const likeSchema = new Schema(
4+
{
5+
comment: { type: Schema.Types.ObjectId, ref: "Comment", required: true },
6+
// owner: { type: Schema.Types.ObjectId, ref: "User", required: true },
7+
video: { type: Schema.Types.ObjectId, ref: "Video", required: true },
8+
likedBy: [{ type: Schema.Types.ObjectId, ref: "User" }],
9+
// dislikes: [{ type: Schema.Types.ObjectId, ref: "User" }],
10+
tweet: [{ type: Schema.Types.ObjectId, ref: "Tweet" }],
11+
},
12+
{ timestamps: true }
13+
);
14+
15+
export const Like = mongoose.model("Like", likeSchema);

src/models/playList.model.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import mongoose, { Schema } from "mongoose";
2+
3+
const playListSchema = new Schema(
4+
{
5+
name: { type: String, req: true },
6+
discription: { type: String, req: true },
7+
videos: [
8+
{
9+
type: mongoose.Schema.Types.ObjectId,
10+
ref: "Video",
11+
},
12+
],
13+
owner: { type: Schema.Types.ObjectId, ref: "User" },
14+
},
15+
{ timestamps: true }
16+
);
17+
18+
export const PlayList = mongoose.model("PlayList", playListSchema);

src/models/tweet.model.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import mongoose, { Schema } from "mongoose";
2+
3+
const tweetSchema = new Schema(
4+
{
5+
content: { type: String, required: true },
6+
owner: { type: Schema.Types.ObjectId, ref: "User", required: true },
7+
},
8+
{ timestamps: true }
9+
);
10+
11+
export const Tweet = mongoose.model("Tweet", tweetSchema);

0 commit comments

Comments
 (0)