Enable logging in mongodb tables
This commit is contained in:
parent
add5018f7c
commit
c1c4786579
@ -155,8 +155,19 @@ class MongodbTable<Default extends Document = Document> extends Table
|
||||
if ('_id' in query && !(query._id instanceof ObjectId))
|
||||
{
|
||||
if (typeof query._id === 'string' && query._id.length === 24)
|
||||
query._id = new ObjectId(query._id);
|
||||
{
|
||||
try
|
||||
{
|
||||
const _id = new ObjectId(query._id);
|
||||
query._id = _id;
|
||||
}
|
||||
catch
|
||||
{
|
||||
this.logger.warn(`Invalid ObjectId given ${query._id}`);
|
||||
}
|
||||
}
|
||||
else if (query._id instanceof Array)
|
||||
{
|
||||
query._id = {
|
||||
$in: Object.values(query._id).map((id) =>
|
||||
{
|
||||
@ -164,6 +175,7 @@ class MongodbTable<Default extends Document = Document> extends Table
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
else if (query instanceof Array)
|
||||
{
|
||||
query.forEach(obj =>
|
||||
|
@ -138,7 +138,7 @@ abstract class Provider implements Initialisable
|
||||
return this.#config;
|
||||
}
|
||||
|
||||
protected get logger ()
|
||||
get logger ()
|
||||
{
|
||||
return this.#logger;
|
||||
}
|
||||
|
@ -11,6 +11,10 @@ class Table
|
||||
this.#provider = provider;
|
||||
}
|
||||
|
||||
get logger ()
|
||||
{
|
||||
return this.#provider.logger;
|
||||
}
|
||||
get name ()
|
||||
{
|
||||
return this.#name;
|
||||
|
Loading…
Reference in New Issue
Block a user