User Schema
Closed this issue · 1 comments
kailinc commented
Change from having a property called skill that is an array of objects, where each object has the property name and level, to having each language be a property.
This is because when I update the skill property, mongo will erase all the other stuff in it.
kailinc commented
Each skill is now a property in the user.
const userSchema = new mongoose.Schema({
firstName: {
type: String
},
lastName: {
type: String
},
coderName: {
type: String
},
devCred: {
type: Number,
default: 0
},
fourScreens: {
type: Boolean,
default: false
},
JavaScript: {
type: Number,
default: 0,
min: 0,
max: 9000
},
Python: {
type: Number,
default: 0,
min: 0,
max: 9000
},
C: {
type: Number,
default: 0,
min: 0,
max: 9000
},
Css: {
type: Number,
default: 0,
min: 0,
max: 9000
},
Go: {
type: Number,
default: 0,
min: 0,
max: 9000
},
Html: {
type: Number,
default: 0,
min: 0,
max: 9000
},
Java: {
type: Number,
default: 0,
min: 0,
max: 9000
},
Ruby: {
type: Number,
default: 0,
min: 0,
max: 9000
},
Angular: {
type: Number,
default: 0,
min: 0,
max: 9000
},
React: {
type: Number,
default: 0,
min: 0,
max: 9000
},
BootStrap: {
type: Number,
default: 0,
min: 0,
max: 9000
},
Django: {
type: Number,
default: 0,
min: 0,
max: 9000
},
Ember: {
type: Number,
default: 0,
min: 0,
max: 9000
},
MongoDB: {
type: Number,
default: 0,
min: 0,
max: 9000
},
Sql: {
type: Number,
default: 0,
min: 0,
max: 9000
},
Node: {
type: Number,
default: 0,
min: 0,
max: 9000
},
Rails: {
type: Number,
default: 0,
min: 0,
max: 9000
},
powers: [{
name: {
type: String,
required: true
},
img: {
type: String,
required: true
}
}],
email: {
type: String,
unique: true,
required: true
},
token: {
type: String,
required: true
},
passwordDigest: String
}, {
timestamps: true,
toJSON: {
virtuals: true,
transform: function (doc, pojoUser) {
// remove sensitive data from every user document
delete pojoUser.token
delete pojoUser.passwordDigest
return pojoUser
}
},
toObject: {
virtuals: true
}
})