Created
September 18, 2016 06:13
-
-
Save tithi021/e8a76ac657758421aef7cfbe26bcbd70 to your computer and use it in GitHub Desktop.
Mongodb User schema model design of social platform.
This file contains hidden or 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
var mongoose = require('mongoose'); | |
var Schema = mongoose.Schema; | |
var UserSchema = new Schema({ | |
username: { | |
type: String, | |
unique: true, | |
required: true | |
}, | |
fullname: String, | |
email: { | |
type: String, | |
unique: true, | |
index: true, | |
lowercase: true, | |
required: true | |
}, | |
userType: {type: String, enum:['user','admin'], default: 'user'}, | |
password: { | |
type: String, | |
required: true | |
}, | |
// Contact Informations | |
contactInformations: { | |
phone: Number, | |
website: String, | |
address: String | |
}, | |
// Work Information | |
workInformations: [{ | |
designation: String, | |
company: String, | |
location: String, | |
startDate: Date, | |
endDate: Date, | |
isContinue: Boolean | |
}], | |
// Education | |
educationInformations: [{ | |
school: String, | |
startDate: Date, | |
endDate: Date, | |
degree: String, | |
isContinue: Boolean, | |
fieldOfStudy: String, | |
description: String | |
}], | |
profilePhoto: String, | |
coverPhoto: String, | |
emailVerification: { | |
type: Boolean, | |
default: false | |
}, | |
// Friends Request | |
friends: [{ | |
userId: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, | |
status: { | |
type: Boolean, | |
default: false | |
}, | |
requestSendDate: { | |
type: Date, | |
default: Date.now | |
}, | |
requestAcceptedDate: { | |
type: Date, | |
default: Date.now | |
} | |
}], | |
aboutme: String, | |
birthday: Date, | |
gender: String, | |
createdDate: { | |
type: Date, | |
default: Date.now | |
}, | |
updatedDate: Date, | |
tokenKey: String, // Randomly generated token key for api access | |
salt: String, // unique salt for reset password | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment