-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers.js
More file actions
38 lines (33 loc) · 784 Bytes
/
users.js
File metadata and controls
38 lines (33 loc) · 784 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
33
34
35
36
37
38
const mongoose = require('mongoose');
mongoose.connect('mongodb://127.0.0.1:27017/pinterestmini');
const plm = require('passport-local-mongoose')
// Define the schema for the User model
const userSchema = new mongoose.Schema({
username: {
type: String,
required: true,
unique: true
},
password: {
type: String
},
fullname: {
type: String,
required: true
},
email: {
type: String,
required: true,
unique: true
},
dp: {
type: String // Assuming dp is a URL pointing to the display picture
},
posts: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'Post' // Reference from Post model
}]
});
userSchema.plugin(plm);
// Create the User model using the schema
module.exports = mongoose.model('User', userSchema);