]>
git.r.bdr.sh - rbdr/lgtm/blob - lib/record_fetcher.js
3 const Config
= require('../config/config');
4 const Mysql
= require('mysql2');
8 module
.exports
= internals
.Record
= class {
12 this.connection
= Mysql
.createConnection(Config
.mysql
);
17 return new Promise((resolve
, reject
) => {
18 this.connection
.query(`SELECT * FROM ${Config.mysql.tableName} ORDER BY RAND() LIMIT 1`, (err
, results
) => {
21 console
.error('Error while fetching row');
22 console
.error(err
.message
);
26 if (results
.length
=== 0) {
27 const error
= new Error('No rows found.');
28 console
.error('Error while fetching row');
29 console
.error(error
.message
);
33 const row
= results
[0];