1
0

Video 83: Setting up Mongoose

This commit is contained in:
JayWll
2020-02-15 17:42:08 -07:00
parent 3a357614bc
commit 9c5bc6c18c
3 changed files with 135 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
const mongoose = require('mongoose')
mongoose.connect('mongodb://localhost:27017/task-manager-api', {
useNewUrlParser: true,
useCreateIndex: true
})
const User = mongoose.model('User', {
name: {
type: String
},
age: {
type: Number
}
})
const me = new User({
name: 'Jason',
age: 'Mike'
})
me.save().then(() => {
console.log(me)
}).catch((error) => {
console.log('Error!', error)
})