Fix Typo and utsing utils empty array check
MODIFY
src/server/rest/service/CarService.ts
src/server/rest/service/CarService.ts
@@ -3,7 +3,6 @@ import { Car, UserCar } from '../../../types/Car';
import { HTTPAuthError, HTTPError } from '../../../types/HTTPError';
import { NextFunction, Request, Response } from 'express';
-import { ActionsResponse } from '../../../types/GlobalType';
import AppAuthError from '../../../exception/AppAuthError';
import AppError from '../../../exception/AppError';
import Authorizations from '../../../authorization/Authorizations';

MODIFY
src/storage/mongodb/CarStorage.ts
src/storage/mongodb/CarStorage.ts
@@ -47,7 +47,7 @@ export default class CarStorage {
// Create Aggregation
const aggregation = [];
// Limit on Car for Basic Users
- if (params.carCatalogIDs && params.carCatalogIDs.length > 0) {
+ if (!Utils.isEmptyArray(params.carCatalogIDs)) {
// Build filter
aggregation.push({
$match: {
@@ -650,18 +650,18 @@ export default class CarStorage {
];
}
// Limit on Car for Basic Users
- if (params.carIDs && params.carIDs.length > 0) {
+ if (!Utils.isEmptyArray(params.carIDs)) {
// Build filter
filters._id = { $in: params.carIDs.map((carID) => Utils.convertToObjectID(carID)) };
}
// Create Aggregation
const aggregation = [];
- if ((params.userIDs && params.userIDs.length > 0) || params.withUsers) {
+ if (!Utils.isEmptyArray(params.userIDs) || params.withUsers) {
DatabaseUtils.pushUserCarLookupInAggregation({
tenantID: tenantID, aggregation, localField: '_id', foreignField: 'carID',
asField: 'userscars', oneToOneCardinality: false
});
- if (params.userIDs && params.userIDs.length > 0) {
+ if (!Utils.isEmptyArray(params.userIDs)) {
filters['userscars.userID'] = { $in: params.userIDs.map((userID) => Utils.convertToObjectID(userID)) };
}
if (params.defaultCar) {
@@ -788,15 +788,15 @@ export default class CarStorage {
filters.active = params.active;
}
// Limit on Car for Basic Users
- if (params.userscarsIDs && params.userscarsIDs.length > 0) {
+ if (!Utils.isEmptyArray(params.userscarsIDs)) {
// Build filter
filters._id = { $in: params.userscarsIDs.map((userscarsID) => Utils.convertToObjectID(userscarsID)) };
}
- if (params.carIDs && params.carIDs.length > 0) {
+ if (!Utils.isEmptyArray(params.carIDs)) {
// Build filter
filters.carID = { $in: params.carIDs.map((carID) => Utils.convertToObjectID(carID)) };
}
- if (params.userIDs && params.userIDs.length > 0) {
+ if (!Utils.isEmptyArray(params.userIDs)) {
// Build filter
filters.userID = { $in: params.userIDs.map((userID) => Utils.convertToObjectID(userID)) };
}

MODIFY
src/types/Authorization.ts
src/types/Authorization.ts
@@ -70,7 +70,7 @@ export enum Entity {
CAR = 'Car',
CARS = 'Cars',
USER_CAR='UserCar',
- USERS_CARS='usersCars',
+ USERS_CARS='UsersCars',
INVOICE = 'Invoice',
INVOICES = 'Invoices',
TAXES = 'Taxes',

Fix Typo and utsing utils empty array check