1
0
Fork 0

Video 84: Creating a Mongoose Model

This commit is contained in:
JayWll 2020-02-15 17:50:45 -07:00
parent 9c5bc6c18c
commit 72d2114a6c
1 changed files with 25 additions and 5 deletions

View File

@ -14,13 +14,33 @@ const User = mongoose.model('User', {
} }
}) })
const me = new User({ const Task = mongoose.model('Task', {
name: 'Jason', description: {
age: 'Mike' type: String
},
completed: {
type: Boolean
}
}) })
me.save().then(() => { const task = new Task({
console.log(me) description: 'Learn the Mongoose library',
completed: false
})
task.save().then(() => {
console.log(task);
}).catch((error) => { }).catch((error) => {
console.log('Error!', error) console.log('Error!', error)
}) })
// const me = new User({
// name: 'Jason',
// age: 'Mike'
// })
//
// me.save().then(() => {
// console.log(me)
// }).catch((error) => {
// console.log('Error!', error)
// })