Created
February 18, 2020 11:03
-
-
Save iamdylanngo/db4e4e7bc9d084a1514e926d1023e68c to your computer and use it in GitHub Desktop.
mongoose-db
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
var conn = mongoose.connect('mongodb://admin:123456@localhost:27017', { | |
useNewUrlParser: true, | |
useUnifiedTopology: true, | |
serverSelectionTimeoutMS: 5000 | |
}).then(() => { | |
console.log("Connected to DB"); | |
}).catch((err) => { | |
console.log(err); | |
}); | |
const userSchema = new mongoose.Schema({ username: String, password: String }); | |
const UserModel = mongoose.model('User', userSchema); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment