forked from hiteshchoudhary/chai-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add comment, like, playlist, and tweet models
- Loading branch information
1 parent
7c91a52
commit 0150103
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |