From 72d2114a6c961bb946606dbc1edc980a14b85dd2 Mon Sep 17 00:00:00 2001 From: JayWll Date: Sat, 15 Feb 2020 17:50:45 -0700 Subject: [PATCH] Video 84: Creating a Mongoose Model --- task-manager/src/db/mongoose.js | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/task-manager/src/db/mongoose.js b/task-manager/src/db/mongoose.js index 7034052..4983b98 100644 --- a/task-manager/src/db/mongoose.js +++ b/task-manager/src/db/mongoose.js @@ -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) +// })