Compare commits
No commits in common. "ef5449509e690fda3681ab29df2138290edf9156" and "687494727bfa8e3309a3c04969c8e70c21ec56dc" have entirely different histories.
ef5449509e
...
687494727b
1
.gitignore
vendored
1
.gitignore
vendored
@ -131,4 +131,3 @@ dist
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
credentials.json
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@navy.gif/wrappers",
|
||||
"version": "1.3.8",
|
||||
"version": "1.3.7",
|
||||
"description": "Various wrapper classes I use in my projects",
|
||||
"repository": "https://git.corgi.wtf/Navy.gif/wrappers.git",
|
||||
"author": "Navy.gif",
|
||||
|
@ -149,7 +149,6 @@ class MariaDB {
|
||||
this.#pool?.removeAllListeners();
|
||||
resolve();
|
||||
});
|
||||
this.#pool = null;
|
||||
});
|
||||
}
|
||||
|
||||
@ -180,7 +179,7 @@ class MariaDB {
|
||||
const connection = await this.getConnection();
|
||||
try {
|
||||
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)
|
||||
reject(err);
|
||||
else if (results)
|
||||
@ -215,8 +214,8 @@ class MariaDB {
|
||||
|
||||
}
|
||||
|
||||
q<T> (query: string, values: (string | number | string[] | number[])[], timeout?: number) {
|
||||
return this.query<T>(query, values, timeout);
|
||||
q (query: string, values: (string | number | string[] | number[])[], timeout?: number) {
|
||||
return this.query(query, values, timeout);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
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";
|
||||
|
||||
type Credentials = {
|
||||
@ -327,7 +327,7 @@ class MongoDB {
|
||||
return this.#db.collection(coll);
|
||||
}
|
||||
|
||||
async ensureIndex (collection: string, indices: IndexSpecification = []) {
|
||||
async ensureIndex (collection: string, indices: string[] = []) {
|
||||
if (!this.#db)
|
||||
throw new Error(`MongoDB not connected`);
|
||||
if (!(indices instanceof Array))
|
||||
|
@ -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();
|
Loading…
Reference in New Issue
Block a user