-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost.model.js
More file actions
32 lines (27 loc) · 1023 Bytes
/
post.model.js
File metadata and controls
32 lines (27 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const mongoose = require('mongoose');
// Define schema for User
const userSchema = new mongoose.Schema({
UserId: { type: Number, required: true },
name: { type: String, required: true },
username: { type: String, required: true },
email: { type: String, required: true },
});
// Define schema for Post
const postSchema = new mongoose.Schema({
PostId: { type: Number, required: true },
UserId: { type: Number, required: true },
title: { type: String, required: true },
body: { type: String }
});
// Define schema for Comment
const commentSchema = new mongoose.Schema({
UserId: { type: Number, required: true },
PostId: { type: Number, required: true },
username: { type: String, required: true },
body: { type: String, required: true }
});
// Create models for each schema
const User = mongoose.model('User', userSchema);
const Post = mongoose.model('Post', postSchema);
const Comment = mongoose.model('Comment', commentSchema);
module.exports = { User, Post, Comment };