Compare commits
No commits in common. "d781458cee73c261c5f476ecb2d6e73c3ba36cec" and "613399e9286c4367c3e1faa5a38c367c5e879dbf" have entirely different histories.
d781458cee
...
613399e928
893
.yarn/releases/yarn-4.1.1.cjs
vendored
893
.yarn/releases/yarn-4.1.1.cjs
vendored
File diff suppressed because one or more lines are too long
@ -1,5 +0,0 @@
|
||||
nodeLinker: node-modules
|
||||
|
||||
yarnPath: .yarn/releases/yarn-4.1.1.cjs
|
||||
|
||||
npmRegistryServer: "https://registry.corgi.wtf"
|
14
package.json
14
package.json
@ -1,10 +1,11 @@
|
||||
{
|
||||
"name": "@navy.gif/wrappers",
|
||||
"version": "1.8.0",
|
||||
"version": "1.7.8",
|
||||
"description": "Various wrapper classes I use in my projects",
|
||||
"repository": "https://git.corgi.wtf/Navy.gif/wrappers.git",
|
||||
"author": "Navy.gif",
|
||||
"license": "MIT",
|
||||
"private": false,
|
||||
"type": "module",
|
||||
"main": "build/cjs/index.js",
|
||||
"module": "build/esm/index.js",
|
||||
@ -25,9 +26,7 @@
|
||||
"build:cjs": "tsc -p tsconfig.cjs.json && node ./scripts/declareTypes.js --common",
|
||||
"build:module": "tsc && node ./scripts/declareTypes.js --module",
|
||||
"test": "yarn build && jest",
|
||||
"release:patch": "yarn build && yarn version patch && yarn npm publish",
|
||||
"release:minor": "yarn build && yarn version minor && yarn npm publish",
|
||||
"release:major": "yarn build && yarn version major && yarn npm publish",
|
||||
"release": "yarn build && yarn publish",
|
||||
"lint": "eslint --fix"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -36,14 +35,14 @@
|
||||
"@typescript-eslint/eslint-plugin": "^5.57.1",
|
||||
"@typescript-eslint/parser": "^5.57.1",
|
||||
"eslint": "^8.37.0",
|
||||
"typescript": "^5.4.3"
|
||||
"typescript": "^5.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/amqplib": "^0.10.1",
|
||||
"@types/mysql": "^2.15.21",
|
||||
"amqp-connection-manager": "^4.1.12",
|
||||
"amqplib": "^0.10.3",
|
||||
"mongodb": "^6.5.0",
|
||||
"mongodb": "^6.3.0",
|
||||
"mysql": "^2.18.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
@ -53,6 +52,5 @@
|
||||
"prom-client": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"packageManager": "yarn@4.1.1"
|
||||
}
|
||||
}
|
||||
|
@ -124,6 +124,7 @@ class MessageBroker
|
||||
|
||||
async init ()
|
||||
{
|
||||
|
||||
if (!this.#load)
|
||||
return this.#logger?.info('Not loading RabbitMQ');
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { inspect } from 'node:util';
|
||||
import { MongoClient, MongoClientOptions, Db, Document, WithId, ObjectId, Filter, IndexSpecification, CreateIndexesOptions, FindOptions, ModifyResult, DistinctOptions } from 'mongodb';
|
||||
import { MongoClient, MongoClientOptions, Db, Document, WithId, ObjectId, Filter, IndexSpecification, CreateIndexesOptions, FindOptions, ModifyResult } from 'mongodb';
|
||||
import { IServer, ILogger } from './interfaces/index.js';
|
||||
|
||||
type Credentials = {
|
||||
@ -61,6 +61,7 @@ class MongoDB
|
||||
|
||||
constructor (server: IServer, config: MongoOptions)
|
||||
{
|
||||
|
||||
if (!server)
|
||||
throw new Error('Missing reference to server!');
|
||||
if (!config)
|
||||
@ -107,6 +108,7 @@ class MongoDB
|
||||
.on('timeout', () => this.#logger?.warn('MongoDB timed out'))
|
||||
.on('close', () => this.#logger?.info('MongoDB client disconnected'))
|
||||
.on('open', () => this.#logger?.info('MongoDB client connected'));
|
||||
|
||||
}
|
||||
|
||||
get database ()
|
||||
@ -348,24 +350,6 @@ class MongoDB
|
||||
return result;
|
||||
}
|
||||
|
||||
async distinct<T extends Document> (db: string, key: string, filter: Filter<T> = {}, options: DistinctOptions = {})
|
||||
{
|
||||
if (!this.#db)
|
||||
throw new Error('MongoDB not connected');
|
||||
if (typeof db !== 'string')
|
||||
throw new Error('Expecting collection name for the first argument');
|
||||
if (filter && typeof filter._id === 'string' && filter._id.length === 24)
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
filter._id = new ObjectId(filter._id);
|
||||
|
||||
const endTimer = MongoDB.#queryHistogram?.startTimer({ type: 'distinct' });
|
||||
const result = await this.#db.collection<T>(db).distinct(key, filter, options);
|
||||
if (endTimer)
|
||||
endTimer();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push data to an array
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user