aboutsummaryrefslogtreecommitdiff
path: root/lib/record_fetcher.js
diff options
context:
space:
mode:
authorRuben Beltran del Rio <ruben@unlimited.pizza>2021-12-20 00:11:18 +0100
committerRuben Beltran del Rio <ruben@unlimited.pizza>2021-12-20 00:11:18 +0100
commit92ccd82c73463fa0b67996dc9212e992f90a1454 (patch)
tree456f16a2a88c3f9613c9eaf3dcdf3876aa36d689 /lib/record_fetcher.js
parent55fd5e33b1430fd6498f476490da6b5fa6abd70c (diff)
Port to svelteHEADsveltemain
Diffstat (limited to 'lib/record_fetcher.js')
-rw-r--r--lib/record_fetcher.js45
1 files changed, 0 insertions, 45 deletions
diff --git a/lib/record_fetcher.js b/lib/record_fetcher.js
deleted file mode 100644
index a506fe7..0000000
--- a/lib/record_fetcher.js
+++ /dev/null
@@ -1,45 +0,0 @@
-'use strict';
-
-const Config = require('../config/config');
-const Mysql = require('mysql2');
-
-const internals = {};
-
-module.exports = internals.Record = class {
-
- constructor() {
-
- this.connection = Mysql.createConnection(Config.mysql);
- }
-
- fetch() {
-
- return new Promise((resolve, reject) => {
- this.connection.query(`SELECT * FROM ${Config.mysql.tableName} ORDER BY RAND() LIMIT 1`, (err, results) => {
-
- if (err) {
- console.error('Error while fetching row');
- console.error(err.message);
- return reject(err);
- }
-
- if (results.length === 0) {
- const error = new Error('No rows found.');
- console.error('Error while fetching row');
- console.error(error.message);
- return reject(err);
- }
-
- const row = results[0];
-
- return resolve({
- looks: row.l,
- good: row.g,
- to: row.t,
- me: row.m,
- emoji: row.emoji
- });
- });
- });
- }
-};