Last active
February 10, 2019 09:46
-
-
Save mhemrg/08a0f4d918deb1048dee983389ed5d74 to your computer and use it in GitHub Desktop.
Connect to MongoDB in NodeJS with Mongoose | Liara
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require('mongoose'); | |
mongoose.connect('mongodb://root:[email protected]:PORT/cats_db', { | |
useNewUrlParser: true, | |
authSource: 'admin', | |
}); | |
const Cat = mongoose.model('Cat', { name: String }); | |
const kitty = new Cat({ name: 'Kitty' }); | |
kitty.save().then(() => console.log('Cat added.')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment