Last active
August 6, 2018 22:41
-
-
Save DiegoPinho/e58559efc27ac451f21104e9013bca3c to your computer and use it in GitHub Desktop.
This file contains 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
// instância do MongoClient | |
const MongoClient = require('mongodb').MongoClient; | |
// conexão com o banco de dados remoto exemplomlab | |
const url = 'SUA_URL_AQUI'; | |
MongoClient.connect(url, (err, db) => { | |
if(!err) { | |
console.log('Conectado'); | |
} | |
//criação da collection Artigos | |
db.collection('Artigos', (err, collection) => { | |
collection.insert({title: 'Artigo 1'}); | |
collection.insert({title: 'Artigo 2'}); | |
collection.insert({title: 'Artigo 3'}); | |
db.collection('Artigos').count((err, count) => { | |
if (err) throw err; | |
console.log('total linhas inseridas: ' + count); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment