Compare commits

..

2 Commits

Author SHA1 Message Date
15dd706009 v1.7.7 2024-01-09 17:20:08 +02:00
ae41d56259 bugfix 2024-01-09 17:19:51 +02:00
2 changed files with 10 additions and 10 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@navy.gif/wrappers", "name": "@navy.gif/wrappers",
"version": "1.7.6", "version": "1.7.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

@ -194,7 +194,7 @@ class MongoDB
if (typeof db !== 'string') if (typeof db !== 'string')
throw new TypeError('Expecting collection name for the first argument'); throw new TypeError('Expecting collection name for the first argument');
if (typeof query._id === 'string') if (typeof query._id === 'string' && query._id.length === 24)
query._id = new ObjectId(query._id); query._id = new ObjectId(query._id);
this.#logger.debug(`Incoming find query for ${db} with parameters ${inspect(query)}`); this.#logger.debug(`Incoming find query for ${db} with parameters ${inspect(query)}`);
@ -222,7 +222,7 @@ class MongoDB
if (typeof db !== 'string') if (typeof db !== 'string')
throw new TypeError('Expecting collection name for the first argument'); throw new TypeError('Expecting collection name for the first argument');
if (typeof query._id === 'string') if (typeof query._id === 'string' && query._id.length === 24)
query._id = new ObjectId(query._id); query._id = new ObjectId(query._id);
this.#logger.debug(`Incoming findOne query for ${db} with parameters ${inspect(query)}`); this.#logger.debug(`Incoming findOne query for ${db} with parameters ${inspect(query)}`);
@ -250,7 +250,7 @@ class MongoDB
throw new TypeError('Expecting collection name for the first argument'); throw new TypeError('Expecting collection name for the first argument');
if (!filter) if (!filter)
throw new Error('Cannot run update many without a filter, if you mean to update every single document, pass an empty object'); throw new Error('Cannot run update many without a filter, if you mean to update every single document, pass an empty object');
if (typeof filter._id === 'string') if (typeof filter._id === 'string' && filter._id.length === 24)
filter._id = new ObjectId(filter._id); filter._id = new ObjectId(filter._id);
this.#logger.debug(`Incoming update query for '${db}' with parameters\n${inspect(filter)}\nand data\n${inspect(data)}`); this.#logger.debug(`Incoming update query for '${db}' with parameters\n${inspect(filter)}\nand data\n${inspect(data)}`);
@ -276,7 +276,7 @@ class MongoDB
throw new Error('MongoDB not connected'); throw new Error('MongoDB not connected');
if (typeof db !== 'string') if (typeof db !== 'string')
throw new TypeError('Expecting collection name for the first argument'); throw new TypeError('Expecting collection name for the first argument');
if (typeof filter._id === 'string') if (typeof filter._id === 'string' && filter._id.length === 24)
filter._id = new ObjectId(filter._id); filter._id = new ObjectId(filter._id);
this.#logger.debug(`Incoming updateOne query for ${db} with parameters ${inspect(filter)}`); this.#logger.debug(`Incoming updateOne query for ${db} with parameters ${inspect(filter)}`);
@ -302,7 +302,7 @@ class MongoDB
throw new Error('MongoDB not connected'); throw new Error('MongoDB not connected');
if (typeof db !== 'string') if (typeof db !== 'string')
throw new TypeError('Expecting collection name for the first argument'); throw new TypeError('Expecting collection name for the first argument');
if (typeof data._id === 'string') if (typeof data._id === 'string' && data._id.length === 24)
data._id = new ObjectId(data._id); data._id = new ObjectId(data._id);
this.#logger.debug(`Incoming insertOne query for ${db} with parameters ${inspect(data)}`); this.#logger.debug(`Incoming insertOne query for ${db} with parameters ${inspect(data)}`);
@ -319,7 +319,7 @@ class MongoDB
throw new Error('MongoDB not connected'); throw new Error('MongoDB not connected');
if (typeof db !== 'string') if (typeof db !== 'string')
throw new TypeError('Expecting collection name for the first argument'); throw new TypeError('Expecting collection name for the first argument');
if (typeof filter._id === 'string') if (typeof filter._id === 'string' && filter._id.length === 24)
filter._id = new ObjectId(filter._id); filter._id = new ObjectId(filter._id);
this.#logger.debug(`Incoming deleteOne query for ${db} with parameters ${inspect(filter)}`); this.#logger.debug(`Incoming deleteOne query for ${db} with parameters ${inspect(filter)}`);
@ -338,7 +338,7 @@ class MongoDB
throw new Error('MongoDB not connected'); throw new Error('MongoDB not connected');
if (typeof db !== 'string') if (typeof db !== 'string')
throw new TypeError('Expecting collection name for the first argument'); throw new TypeError('Expecting collection name for the first argument');
if (typeof filter._id === 'string') if (typeof filter._id === 'string' && filter._id.length === 24)
filter._id = new ObjectId(filter._id); filter._id = new ObjectId(filter._id);
const endTimer = MongoDB.#queryHistogram?.startTimer({ type: 'findOneAndDelete' }); const endTimer = MongoDB.#queryHistogram?.startTimer({ type: 'findOneAndDelete' });
@ -364,7 +364,7 @@ class MongoDB
throw new Error('MongoDB not connected'); throw new Error('MongoDB not connected');
if (typeof db !== 'string') if (typeof db !== 'string')
throw new TypeError('Expecting collection name for the first argument'); throw new TypeError('Expecting collection name for the first argument');
if (typeof filter._id === 'string') if (typeof filter._id === 'string' && filter._id.length === 24)
filter._id = new ObjectId(filter._id); filter._id = new ObjectId(filter._id);
this.#logger.debug(`Incoming push query for ${db}, with upsert ${upsert} and with parameters ${inspect(filter)} and data ${inspect(data)}`); this.#logger.debug(`Incoming push query for ${db}, with upsert ${upsert} and with parameters ${inspect(filter)} and data ${inspect(data)}`);
@ -390,7 +390,7 @@ class MongoDB
throw new Error('MongoDB not connected'); throw new Error('MongoDB not connected');
if (typeof db !== 'string') if (typeof db !== 'string')
throw new TypeError('Expecting collection name for the first argument'); throw new TypeError('Expecting collection name for the first argument');
if (typeof filter._id === 'string') if (typeof filter._id === 'string' && filter._id.length === 24)
filter._id = new ObjectId(filter._id); filter._id = new ObjectId(filter._id);
this.#logger.debug(`Incoming random query for ${db} with parameters ${inspect(filter)} and amount ${amount}`); this.#logger.debug(`Incoming random query for ${db} with parameters ${inspect(filter)} and amount ${amount}`);