Compare commits

..

No commits in common. "ef5449509e690fda3681ab29df2138290edf9156" and "687494727bfa8e3309a3c04969c8e70c21ec56dc" have entirely different histories.

5 changed files with 6 additions and 33 deletions

1
.gitignore vendored
View File

@ -131,4 +131,3 @@ dist
.yarn/install-state.gz .yarn/install-state.gz
.pnp.* .pnp.*
credentials.json

View File

@ -1,6 +1,6 @@
{ {
"name": "@navy.gif/wrappers", "name": "@navy.gif/wrappers",
"version": "1.3.8", "version": "1.3.7",
"description": "Various wrapper classes I use in my projects", "description": "Various wrapper classes I use in my projects",
"repository": "https://git.corgi.wtf/Navy.gif/wrappers.git", "repository": "https://git.corgi.wtf/Navy.gif/wrappers.git",
"author": "Navy.gif", "author": "Navy.gif",

View File

@ -149,7 +149,6 @@ class MariaDB {
this.#pool?.removeAllListeners(); this.#pool?.removeAllListeners();
resolve(); resolve();
}); });
this.#pool = null;
}); });
} }
@ -180,7 +179,7 @@ class MariaDB {
const connection = await this.getConnection(); const connection = await this.getConnection();
try { try {
const result = await new Promise<T[] | FieldInfo[] | undefined>((resolve, reject) => { const result = await new Promise<T[] | FieldInfo[] | undefined>((resolve, reject) => {
const q = connection.query({ timeout, sql: query }, [ values ], (err, results, fields) => { const q = connection.query({ timeout, sql: query }, values, (err, results, fields) => {
if (err) if (err)
reject(err); reject(err);
else if (results) else if (results)
@ -215,8 +214,8 @@ class MariaDB {
} }
q<T> (query: string, values: (string | number | string[] | number[])[], timeout?: number) { q (query: string, values: (string | number | string[] | number[])[], timeout?: number) {
return this.query<T>(query, values, timeout); return this.query(query, values, timeout);
} }
} }

View File

@ -1,5 +1,5 @@
import { inspect } from "node:util"; import { inspect } from "node:util";
import { MongoClient, MongoClientOptions, Db, Document, WithId, ObjectId, Filter, IndexSpecification } from "mongodb"; import { MongoClient, MongoClientOptions, Db, Document, WithId, ObjectId, Filter } from "mongodb";
import { IServer, ILogger, LoggerClientOptions } from "./interfaces/index.js"; import { IServer, ILogger, LoggerClientOptions } from "./interfaces/index.js";
type Credentials = { type Credentials = {
@ -327,7 +327,7 @@ class MongoDB {
return this.#db.collection(coll); return this.#db.collection(coll);
} }
async ensureIndex (collection: string, indices: IndexSpecification = []) { async ensureIndex (collection: string, indices: string[] = []) {
if (!this.#db) if (!this.#db)
throw new Error(`MongoDB not connected`); throw new Error(`MongoDB not connected`);
if (!(indices instanceof Array)) if (!(indices instanceof Array))

View File

@ -1,25 +0,0 @@
import { readFileSync } from 'fs';
import { MariaDB } from '../build/esm/index.js';
const credentials = JSON.parse(readFileSync('./credentials.json', { encoding: 'utf-8' }));
const maria = new MariaDB({
createLogger: () => {
return {
debug: console.log,
info: console.log,
status: console.log,
warn: console.log,
error: console.error
};
}
}, {
load: true,
credentials
});
await maria.init();
await maria.query('INSERT INTO `test` (`dingle`, `bingle`) VALUES ?', [[ 1, 2 ], [ 3, 4 ], [ 5, 6 ]]);
await maria.close();