trying stuff to mock mysql
This commit is contained in:
@@ -2,12 +2,11 @@ import mysql from "mysql";
|
||||
import logger from "../system/Logger";
|
||||
require("dotenv").config();
|
||||
|
||||
// todo remove export
|
||||
export const db = mysql.createConnection({
|
||||
const db = mysql.createConnection({
|
||||
host: process.env.HOST_DB,
|
||||
user: process.env.USER_DB,
|
||||
password: process.env.PASSWORD_DB,
|
||||
database: process.env.NAME_DB,
|
||||
database: (process.env.NODE_ENV === "test") ? process.env.NAME_DB_TEST : process.env.NAME_DB,
|
||||
});
|
||||
|
||||
db.connect(function (err) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { transformEmojis } from "../utils/string";
|
||||
import { db, execQueryAsync, execQueryAsyncWithId, execQuery } from "./db";
|
||||
import { execQueryAsync, execQueryAsyncWithId, execQuery } from "./db";
|
||||
import { queryFromId, queryToId, queryCcId } from "./utils/addressQueries";
|
||||
|
||||
export async function getAllMembers(messageId: number) {
|
||||
@@ -85,11 +85,10 @@ export async function registerThread(roomId: number, parentId: number, rootId: n
|
||||
|
||||
export async function isRoomGroup(roomId: number): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const query = `SELECT isGroup FROM app_room WHERE room_id = '${roomId}'`;
|
||||
db.query(query, (err, results, fields) => {
|
||||
if (err) reject(err);
|
||||
resolve(results[0].isGroup);
|
||||
});
|
||||
const query = `SELECT isGroup FROM app_room WHERE room_id = ?`;
|
||||
const values = [roomId];
|
||||
const results = execQueryAsync(query, values);
|
||||
return results[0].isGroup;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user