Added Search in DB with ID
MODIFY
src/storage/mongodb/AssetStorage.ts
src/storage/mongodb/AssetStorage.ts
@@ -119,6 +119,9 @@ export default class AssetStorage {
filters.$or = [
{ 'name': { $regex: params.search, $options: 'i' } },
];
+ if (DatabaseUtils.isObjectID(params.search)) {
+ filters.$or.push({ '_id': DatabaseUtils.convertToObjectID(params.search) });
+ }
}
// With no Site Area
if (params.withNoSiteArea) {

MODIFY
src/storage/mongodb/CompanyStorage.ts
src/storage/mongodb/CompanyStorage.ts
@@ -115,6 +115,9 @@ export default class CompanyStorage {
{ 'address.region': { $regex: params.search, $options: 'i' } },
{ 'address.country': { $regex: params.search, $options: 'i' } },
];
+ if (DatabaseUtils.isObjectID(params.search)) {
+ filters.$or.push({ '_id': DatabaseUtils.convertToObjectID(params.search) });
+ }
}
// Limit on Company for Basic Users
if (!Utils.isEmptyArray(params.companyIDs)) {

MODIFY
src/storage/mongodb/SiteAreaStorage.ts
src/storage/mongodb/SiteAreaStorage.ts
@@ -221,6 +221,9 @@ export default class SiteAreaStorage {
{ 'address.country': { $regex: params.search, $options: 'i' } },
{ 'ocpiData.location.id': { $regex: params.search, $options: 'im' } },
];
+ if (DatabaseUtils.isObjectID(params.search)) {
+ filters.$or.push({ '_id': DatabaseUtils.convertToObjectID(params.search) });
+ }
}
// Site Area
if (!Utils.isEmptyArray(params.siteAreaIDs)) {

MODIFY
src/storage/mongodb/SiteStorage.ts
src/storage/mongodb/SiteStorage.ts
@@ -341,6 +341,9 @@ export default class SiteStorage {
{ 'address.country': { $regex: params.search, $options: 'i' } },
{ 'ocpiData.location.id': { $regex: params.search, $options: 'im' } },
];
+ if (DatabaseUtils.isObjectID(params.search)) {
+ filters.$or.push({ '_id': DatabaseUtils.convertToObjectID(params.search) });
+ }
}
// Site Name
if (params.name) {

MODIFY
src/storage/mongodb/UserStorage.ts
src/storage/mongodb/UserStorage.ts
@@ -539,6 +539,9 @@ export default class UserStorage {
{ 'email': { $regex: params.search, $options: 'i' } },
{ 'plateID': { $regex: params.search, $options: 'i' } }
];
+ if (DatabaseUtils.isObjectID(params.search)) {
+ filters.$or.push({ '_id': DatabaseUtils.convertToObjectID(params.search) });
+ }
}
// Users
if (!Utils.isEmptyArray(params.userIDs)) {

Added Search in DB with ID