Created
January 5, 2019 01:49
-
-
Save danielnunesdc/8bcb9985f01d2b8da49ff0e385ba484b to your computer and use it in GitHub Desktop.
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 mongodb = require("mongodb"); | |
const usuario = 'myUserAdmin'; | |
const senha = 'abc123@'; | |
const url = `mongodb://localhost:27017/admin`; | |
mongodb | |
.MongoClient | |
.connect(url) | |
.then((db) => { | |
db.authenticate(usuario, senha) | |
.then(() => { | |
db.db('teste') | |
.collection('admin') | |
.insertOne({funcionando: true}) | |
.then((resultadoOperacao) => { | |
console.log(resultadoOperacao.insertedId); | |
}); | |
}); | |
}) | |
.catch(reason => console.log('Erro ao conectar: ', reason)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment