1var MongoClient = require('mongodb').MongoClient
2
3MongoClient.connect('mongodb://localhost:27017/animals', function (err, client) {
4 if (err) throw err
5
6 var db = client.db('animals')
7
8 db.collection('mammals').find().toArray(function (err, result) {
9 if (err) throw err
10
11 console.log(result)
12 })
13})
14
1var mysql = require('mysql')
2var connection = mysql.createConnection({
3 host: 'localhost',
4 user: 'dbuser',
5 password: 's3kreee7',
6 database: 'my_db'
7})
8
9connection.connect()
10
11connection.query('SELECT 1 + 1 AS solution', function (err, rows, fields) {
12 if (err) throw err
13
14 console.log('The solution is: ', rows[0].solution)
15})
16
17connection.end()
18