Compare commits
No commits in common. "27671f7a7463eb354f9b49f3be0036472f5c6cb3" and "91aa37b00398e4088b31dbfee415f4a39fb4c061" have entirely different histories.
27671f7a74
...
91aa37b003
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@navy.gif/wrappers",
|
||||
"version": "1.3.15",
|
||||
"version": "1.3.13",
|
||||
"description": "Various wrapper classes I use in my projects",
|
||||
"repository": "https://git.corgi.wtf/Navy.gif/wrappers.git",
|
||||
"author": "Navy.gif",
|
||||
|
@ -72,7 +72,7 @@ class MessageBroker {
|
||||
|
||||
#logger: ILogger;
|
||||
#subscribers: Map<string, Subscriber[]>;
|
||||
#consumers: Map<string, {consumer: Consumer, options?: Options.Consume}[]>;
|
||||
#consumers: Map<string, {consumer: Consumer, options: Options.Consume}[]>;
|
||||
|
||||
#_pQueue: InternalPublishMsg[];
|
||||
#_qQueue: InternalQueueMsg[];
|
||||
@ -204,7 +204,7 @@ class MessageBroker {
|
||||
}
|
||||
|
||||
// Consume queue
|
||||
async consume<T> (queue: string, consumer: Consumer<T>, options?: Options.Consume) {
|
||||
async consume<T> (queue: string, consumer: Consumer<T>, options: Options.Consume) {
|
||||
if (!this.#channel)
|
||||
throw new Error('Channel does not exist');
|
||||
|
||||
@ -216,7 +216,7 @@ class MessageBroker {
|
||||
this.#consumers.set(queue, list);
|
||||
}
|
||||
|
||||
private async _consume<T> (queue: string, consumer: Consumer<T>, options?: Options.Consume): Promise<void> {
|
||||
private async _consume<T> (queue: string, consumer: Consumer<T>, options: Options.Consume): Promise<void> {
|
||||
if (!this.#channel)
|
||||
return Promise.reject(new Error('Channel doesn\'t exist'));
|
||||
await this.#channel.consume(queue, async (msg: ConsumeMessage) => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { inspect } from "node:util";
|
||||
import { MongoClient, MongoClientOptions, Db, Document, WithId, ObjectId, Filter, IndexSpecification, CreateIndexesOptions, FindOptions } from "mongodb";
|
||||
import { MongoClient, MongoClientOptions, Db, Document, WithId, ObjectId, Filter, IndexSpecification, CreateIndexesOptions } from "mongodb";
|
||||
import { IServer, ILogger, LoggerClientOptions } from "./interfaces/index.js";
|
||||
|
||||
type Credentials = {
|
||||
@ -136,7 +136,7 @@ class MongoDB {
|
||||
* @returns {Array} An array containing the corresponding objects for the query
|
||||
* @memberof Database
|
||||
*/
|
||||
async find<T extends Document> (db: string, query: MongoQuery, options?: FindOptions<T>): Promise<WithId<T>[]> {
|
||||
async find<T extends Document> (db: string, query: MongoQuery, options?: object): Promise<WithId<T>[]> {
|
||||
|
||||
if (!this.#db)
|
||||
throw new Error(`MongoDB not connected`);
|
||||
@ -162,7 +162,7 @@ class MongoDB {
|
||||
* @returns {Object} An object containing the queried data
|
||||
* @memberof Database
|
||||
*/
|
||||
async findOne<T extends Document> (db: string, query: MongoQuery, options: FindOptions<T> = {}): Promise<WithId<T> | null> {
|
||||
async findOne<T extends Document> (db: string, query: MongoQuery, options = {}): Promise<WithId<T> | null> {
|
||||
|
||||
if (!this.#db)
|
||||
throw new Error(`MongoDB not connected`);
|
||||
@ -333,12 +333,6 @@ class MongoDB {
|
||||
return this.#db.collection(coll);
|
||||
}
|
||||
|
||||
count (coll: string, query: Document) {
|
||||
if (!this.#db)
|
||||
throw new Error(`MongoDB not connected`);
|
||||
return this.#db.collection(coll).countDocuments(query);
|
||||
}
|
||||
|
||||
async ensureIndex (collection: string, indices: IndexSpecification = [], options?: CreateIndexesOptions) {
|
||||
if (!this.#db)
|
||||
throw new Error(`MongoDB not connected`);
|
||||
|
Loading…
Reference in New Issue
Block a user