Avoid params overriding!
MODIFY
src/storage/mongodb/AssetStorage.ts
src/storage/mongodb/AssetStorage.ts
@@ -140,7 +140,6 @@ export default class AssetStorage {
}
// Limit on Asset for Basic Users
if (!Utils.isEmptyArray(params.assetIDs)) {
- // Build filter
filters._id = {
$in: params.assetIDs.map((assetID) => Utils.convertToObjectID(assetID))
};

MODIFY
src/storage/mongodb/CarStorage.ts
src/storage/mongodb/CarStorage.ts
@@ -602,7 +602,8 @@ export default class CarStorage {
const carsMDB = await CarStorage.getCars(tenantID, {
licensePlate: licensePlate,
vin: vin,
- ...params
+ withUsers: params.withUsers,
+ userIDs: params.userIDs,
}, Constants.DB_PARAMS_SINGLE_RECORD, projectFields);
return carsMDB.count === 1 ? carsMDB.result[0] : null;
}

MODIFY
src/storage/mongodb/ChargingStationStorage.ts
src/storage/mongodb/ChargingStationStorage.ts
@@ -136,7 +136,9 @@ export default class ChargingStationStorage {
params: { includeDeleted?: boolean, issuer?: boolean; } = {}, projectFields?: string[]): Promise<ChargingStation> {
const chargingStationsMDB = await ChargingStationStorage.getChargingStations(tenantID, {
chargingStationIDs: [id],
- withSite: true, ...params
+ withSite: true,
+ includeDeleted: params.includeDeleted,
+ issuer: params.issuer,
}, Constants.DB_PARAMS_SINGLE_RECORD, projectFields);
return chargingStationsMDB.count === 1 ? chargingStationsMDB.result[0] : null;
}
@@ -145,7 +147,9 @@ export default class ChargingStationStorage {
params: { includeDeleted?: boolean, issuer?: boolean; } = {}, projectFields?: string[]): Promise<ChargingStation> {
const chargingStationsMDB = await ChargingStationStorage.getChargingStations(tenantID, {
chargingStationSerialNumbers: [chargingStationSerialNumber],
- withSite: true, ...params
+ withSite: true,
+ includeDeleted: params.includeDeleted,
+ issuer: params.issuer,
}, Constants.DB_PARAMS_SINGLE_RECORD, projectFields);
return chargingStationsMDB.count === 1 ? chargingStationsMDB.result[0] : null;
}

MODIFY
src/storage/mongodb/SiteStorage.ts
src/storage/mongodb/SiteStorage.ts
@@ -20,7 +20,8 @@ export default class SiteStorage {
params: { withCompany?: boolean, withImage?: boolean; } = {}, projectFields?: string[]): Promise<Site> {
const sitesMDB = await SiteStorage.getSites(tenantID, {
siteIDs: [id],
- ...params,
+ withCompany: params.withCompany,
+ withImage: params.withImage,
}, Constants.DB_PARAMS_SINGLE_RECORD, projectFields);
return sitesMDB.count === 1 ? sitesMDB.result[0] : null;
}

MODIFY
src/storage/mongodb/UserStorage.ts
src/storage/mongodb/UserStorage.ts
@@ -108,10 +108,10 @@ export default class UserStorage {
public static async getUser(tenantID: string, id: string = Constants.UNKNOWN_OBJECT_ID,
params: { withImage?: boolean; siteIDs?: string[]; } = {}, projectFields?: string[]): Promise<User> {
- const userMDB = await UserStorage.getUsers(tenantID,
- {
+ const userMDB = await UserStorage.getUsers(tenantID, {
userIDs: [id],
- ...params
+ withImage: params.withImage,
+ siteIDs: params.siteIDs,
}, Constants.DB_PARAMS_SINGLE_RECORD, projectFields);
return userMDB.count === 1 ? userMDB.result[0] : null;
}

Avoid params overriding!