Embellish the code
MODIFY
src/storage/mongodb/TenantStorage.ts
src/storage/mongodb/TenantStorage.ts
@@ -211,19 +211,16 @@ export default class TenantStorage {
public static async getTenantLogo(tenant: Tenant): Promise<TenantLogo> {
const startTime = Logging.traceDatabaseRequestStart();
DatabaseUtils.checkTenantObject(tenant);
- if (DatabaseUtils.isObjectID(tenant.id)) {
+ let tenantLogoMDB: { _id: ObjectId; logo: string };
// Read DB
- const tenantLogoMDB = await global.database.getCollection<{ _id: ObjectId; logo: string }>(Constants.DEFAULT_TENANT_ID, 'tenantlogos')
+ if (DatabaseUtils.isObjectID(tenant.id)) {
+ tenantLogoMDB = await global.database.getCollection<any>(Constants.DEFAULT_TENANT_ID, 'tenantlogos')
.findOne({ _id: DatabaseUtils.convertToObjectID(tenant.id) });
await Logging.traceDatabaseRequestEnd(tenant, MODULE_NAME, 'getTenantLogo', startTime, { id: tenant.id }, tenantLogoMDB);
- return {
- id: tenant.id,
- logo: tenantLogoMDB ? tenantLogoMDB.logo : null
- };
}
return {
id: tenant.id,
- logo: null
+ logo: tenantLogoMDB?.logo ?? null
};
}
}

Embellish the code