Fix build error after upgrading the mongodb driver
MODIFY
src/storage/mongodb/AsyncTaskStorage.ts
src/storage/mongodb/AsyncTaskStorage.ts
@@ -144,7 +144,7 @@ export default class AsyncTaskStorage {
public static async deleteAsyncTask(id: string): Promise<void> {
const startTime = Logging.traceDatabaseRequestStart();
// Delete the AsyncTask
- await global.database.getCollection<AsyncTask>(Constants.DEFAULT_TENANT, 'asynctasks')
+ await global.database.getCollection<any>(Constants.DEFAULT_TENANT, 'asynctasks')
.findOneAndDelete({ '_id': id });
await Logging.traceDatabaseRequestEnd(Constants.DEFAULT_TENANT_OBJECT, MODULE_NAME, 'deleteAsyncTask', startTime, { id });
}

MODIFY
src/storage/mongodb/CarStorage.ts
src/storage/mongodb/CarStorage.ts
@@ -577,7 +577,7 @@ export default class CarStorage {
public static async deleteCarCatalog(id: number): Promise<void> {
const startTime = Logging.traceDatabaseRequestStart();
// Delete singular site area
- await global.database.getCollection(Constants.DEFAULT_TENANT, 'carcatalogs')
+ await global.database.getCollection<any>(Constants.DEFAULT_TENANT, 'carcatalogs')
.deleteOne({ '_id': id });
await Logging.traceDatabaseRequestEnd(Constants.DEFAULT_TENANT_OBJECT, MODULE_NAME, 'deleteCarCatalog', startTime, { carID: id });
}

MODIFY
src/storage/mongodb/ChargingStationStorage.ts
src/storage/mongodb/ChargingStationStorage.ts
@@ -86,7 +86,7 @@ export default class ChargingStationStorage {
// Validate
chargingStationTemplate = ChargingStationValidatorStorage.getInstance().validateChargingStationTemplate(chargingStationTemplate);
// Modify and return the modified document
- await global.database.getCollection<ChargingStationTemplate>(Constants.DEFAULT_TENANT, 'chargingstationtemplates').findOneAndReplace(
+ await global.database.getCollection<any>(Constants.DEFAULT_TENANT, 'chargingstationtemplates').findOneAndReplace(
{ '_id': chargingStationTemplate.id },
chargingStationTemplate,
{ upsert: true });
@@ -591,7 +591,7 @@ export default class ChargingStationStorage {
const startTime = Logging.traceDatabaseRequestStart();
DatabaseUtils.checkTenantObject(tenant);
// Modify document
- await global.database.getCollection<ChargingStation>(tenant.id, 'chargingstations').findOneAndUpdate(
+ await global.database.getCollection<any>(tenant.id, 'chargingstations').findOneAndUpdate(
{ '_id': id },
{
$set: {
@@ -608,7 +608,7 @@ export default class ChargingStationStorage {
DatabaseUtils.checkTenantObject(tenant);
// Set data
// Modify document
- await global.database.getCollection<ChargingStation>(tenant.id, 'chargingstations').findOneAndUpdate(
+ await global.database.getCollection<any>(tenant.id, 'chargingstations').findOneAndUpdate(
{ '_id': id },
{ $set: params },
{ upsert: true });
@@ -620,7 +620,7 @@ export default class ChargingStationStorage {
const startTime = Logging.traceDatabaseRequestStart();
DatabaseUtils.checkTenantObject(tenant);
// Modify document
- await global.database.getCollection<ChargingStation>(tenant.id, 'chargingstations').findOneAndUpdate(
+ await global.database.getCollection<any>(tenant.id, 'chargingstations').findOneAndUpdate(
{ '_id': id },
{
$set: {
@@ -636,7 +636,7 @@ export default class ChargingStationStorage {
const startTime = Logging.traceDatabaseRequestStart();
DatabaseUtils.checkTenantObject(tenant);
// Modify document
- await global.database.getCollection<ChargingStation>(tenant.id, 'chargingstations').findOneAndUpdate(
+ await global.database.getCollection<any>(tenant.id, 'chargingstations').findOneAndUpdate(
{ '_id': id },
{
$set: {
@@ -651,7 +651,7 @@ export default class ChargingStationStorage {
const startTime = Logging.traceDatabaseRequestStart();
DatabaseUtils.checkTenantObject(tenant);
// Modify document
- await global.database.getCollection<ChargingStation>(tenant.id, 'chargingstations').findOneAndUpdate(
+ await global.database.getCollection<any>(tenant.id, 'chargingstations').findOneAndUpdate(
{ '_id': id },
{ $set: { firmwareUpdateStatus } },
{ upsert: true });
@@ -667,7 +667,7 @@ export default class ChargingStationStorage {
// Delete Charging Profiles
await ChargingStationStorage.deleteChargingProfiles(tenant, id);
// Delete Charging Station
- await global.database.getCollection<ChargingStation>(tenant.id, 'chargingstations')
+ await global.database.getCollection<any>(tenant.id, 'chargingstations')
.findOneAndDelete({ '_id': id });
// Keep the rest (boot notification, authorize...)
await Logging.traceDatabaseRequestEnd(tenant, MODULE_NAME, 'deleteChargingStation', startTime, { id });
@@ -711,8 +711,8 @@ export default class ChargingStationStorage {
const startTime = Logging.traceDatabaseRequestStart();
DatabaseUtils.checkTenantObject(tenant);
// Read DB
- const parametersMDB = await global.database.getCollection<ChargingStationOcppParameters>(tenant.id, 'configurations')
- .findOne({ '_id': id });
+ const parametersMDB = await global.database.getCollection<any>(tenant.id, 'configurations')
+ .findOne({ '_id': id }) as ChargingStationOcppParameters;
if (parametersMDB) {
// Sort
if (parametersMDB.configuration) {
@@ -748,11 +748,9 @@ export default class ChargingStationStorage {
}
public static async getChargingProfiles(tenant: Tenant,
- params: {
- search?: string; chargingStationIDs?: string[]; connectorID?: number; chargingProfileID?: string;
+ params: { search?: string; chargingStationIDs?: string[]; connectorID?: number; chargingProfileID?: string;
profilePurposeType?: ChargingProfilePurposeType; transactionId?: number; withChargingStation?: boolean;
- withSiteArea?: boolean; siteIDs?: string[];
- } = {},
+ withSiteArea?: boolean; siteIDs?: string[]; } = {},
dbParams: DbParams, projectFields?: string[]): Promise<DataResult<ChargingProfile>> {
const startTime = Logging.traceDatabaseRequestStart();
DatabaseUtils.checkTenantObject(tenant);

MODIFY
src/storage/mongodb/ConsumptionStorage.ts
src/storage/mongodb/ConsumptionStorage.ts
@@ -638,6 +638,7 @@ export default class ConsumptionStorage {
instantVoltsL2: Utils.convertToFloat(consumption.instantVoltsL2),
instantVoltsL3: Utils.convertToFloat(consumption.instantVoltsL3),
instantVoltsDC: Utils.convertToFloat(consumption.instantVoltsDC),
+ inactivitySecs: Utils.convertToInt(consumption.inactivitySecs),
totalInactivitySecs: Utils.convertToInt(consumption.totalInactivitySecs),
totalDurationSecs: Utils.convertToInt(consumption.totalDurationSecs),
stateOfCharge: !Utils.isNullOrUndefined(consumption.stateOfCharge) ? Utils.convertToInt(consumption.stateOfCharge) : null,

MODIFY
src/storage/mongodb/MongoDBStorage.ts
src/storage/mongodb/MongoDBStorage.ts
@@ -456,7 +456,7 @@ export default class MongoDBStorage {
// Delete the index
if (!foundIndex) {
if (Utils.isDevelopmentEnv()) {
- const message = `Drop index '${databaseIndex.name}' in collection ${tenantCollectionName}`;
+ const message = `Drop index '${databaseIndex.name as string}' in collection ${tenantCollectionName}`;
Utils.isDevelopmentEnv() && Logging.logConsoleDebug(message);
await Logging.logInfo({
tenantID: Constants.DEFAULT_TENANT,
@@ -468,7 +468,7 @@ export default class MongoDBStorage {
try {
await this.database.collection(tenantCollectionName).dropIndex(databaseIndex.key);
} catch (error) {
- const message = `Error in dropping index '${databaseIndex.name}' in '${tenantCollectionName}': ${error.message}`;
+ const message = `Error in dropping index '${databaseIndex.name as string}' in '${tenantCollectionName}': ${error.message as string}`;
Logging.logConsoleError(message);
await Logging.logError({
tenantID: Constants.DEFAULT_TENANT,

MODIFY
src/storage/mongodb/TransactionStorage.ts
src/storage/mongodb/TransactionStorage.ts
@@ -27,7 +27,7 @@ export default class TransactionStorage {
const startTime = Logging.traceDatabaseRequestStart();
DatabaseUtils.checkTenantObject(tenant);
// Delete
- const result = await global.database.getCollection<Transaction>(tenant.id, 'transactions')
+ const result = await global.database.getCollection<any>(tenant.id, 'transactions')
.deleteMany({ '_id': { $in: transactionsIDs } });
// Delete Meter Values
await global.database.getCollection<any>(tenant.id, 'metervalues')
@@ -213,7 +213,7 @@ export default class TransactionStorage {
const startTime = Logging.traceDatabaseRequestStart();
DatabaseUtils.checkTenantObject(tenant);
// Modify document
- await global.database.getCollection<Transaction>(tenant.id, 'transactions').findOneAndUpdate(
+ await global.database.getCollection<any>(tenant.id, 'transactions').findOneAndUpdate(
{ '_id': id },
{
$set: {
@@ -229,7 +229,7 @@ export default class TransactionStorage {
const startTime = Logging.traceDatabaseRequestStart();
DatabaseUtils.checkTenantObject(tenant);
// Modify document
- await global.database.getCollection<Transaction>(tenant.id, 'transactions').findOneAndUpdate(
+ await global.database.getCollection<any>(tenant.id, 'transactions').findOneAndUpdate(
{ '_id': id },
{
$set: {
@@ -245,7 +245,7 @@ export default class TransactionStorage {
const startTime = Logging.traceDatabaseRequestStart();
DatabaseUtils.checkTenantObject(tenant);
// Modify document
- await global.database.getCollection<Transaction>(tenant.id, 'transactions').findOneAndUpdate(
+ await global.database.getCollection<any>(tenant.id, 'transactions').findOneAndUpdate(
{ '_id': id },
{
$set: {
@@ -261,7 +261,7 @@ export default class TransactionStorage {
const startTime = Logging.traceDatabaseRequestStart();
DatabaseUtils.checkTenantObject(tenant);
// Modify document
- await global.database.getCollection<Transaction>(tenant.id, 'transactions').findOneAndUpdate(
+ await global.database.getCollection<any>(tenant.id, 'transactions').findOneAndUpdate(
{ '_id': id },
{
$set: {

Fix build error after upgrading the mongodb driver