Video 84: Creating a Mongoose Model
This commit is contained in:
parent
9c5bc6c18c
commit
72d2114a6c
@ -14,13 +14,33 @@ const User = mongoose.model('User', {
|
||||
}
|
||||
})
|
||||
|
||||
const me = new User({
|
||||
name: 'Jason',
|
||||
age: 'Mike'
|
||||
const Task = mongoose.model('Task', {
|
||||
description: {
|
||||
type: String
|
||||
},
|
||||
completed: {
|
||||
type: Boolean
|
||||
}
|
||||
})
|
||||
|
||||
me.save().then(() => {
|
||||
console.log(me)
|
||||
const task = new Task({
|
||||
description: 'Learn the Mongoose library',
|
||||
completed: false
|
||||
})
|
||||
|
||||
task.save().then(() => {
|
||||
console.log(task);
|
||||
}).catch((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)
|
||||
// })
|
||||
|
Loading…
Reference in New Issue
Block a user