move car type attribute to user car
MODIFY
src/server/rest/service/CarService.ts
src/server/rest/service/CarService.ts
@@ -250,7 +250,6 @@ export default class CarService {
carCatalogID: filteredRequest.carCatalogID,
licensePlate: filteredRequest.licensePlate,
vin: filteredRequest.vin,
- type: filteredRequest.isPrivate ? 'private' : 'company',
createdBy: { id: req.user.id },
createdOn: new Date()
} as Car;
@@ -268,6 +267,7 @@ export default class CarService {
let newUserCar: UserCar = {
carID: newCar.id,
userID: req.user.id,
+ type: filteredRequest.isPrivate ? 'private' : 'company',
createdBy: { id: req.user.id },
createdOn: new Date()
} as UserCar;

MODIFY
src/storage/mongodb/CarStorage.ts
src/storage/mongodb/CarStorage.ts
@@ -464,7 +464,6 @@ export default class CarStorage {
vin: carToSave.vin,
licensePlate: carToSave.licensePlate,
carCatalogID: Utils.convertToInt(carToSave.carCatalogID),
- type: carToSave.type
};
// Add Last Changed/Created props
DatabaseUtils.addLastChangedCreatedProps(carMDB, carToSave);
@@ -489,6 +488,7 @@ export default class CarStorage {
_id: userCarToSave.id ? Utils.convertToObjectID(userCarToSave.id) : new ObjectID(),
userID: Utils.convertToObjectID(userCarToSave.userID),
carID: Utils.convertToObjectID(userCarToSave.carID),
+ type: userCarToSave.type,
default: userCarToSave.default
};
// Add Last Changed/Created props

MODIFY
src/types/Car.ts
src/types/Car.ts
@@ -130,7 +130,6 @@ export interface Car extends CreatedUpdatedProps {
carCatalog?: CarCatalog;
userIDs?: string;
users?: User[];
- type?: string;
}
export interface UserCar extends CreatedUpdatedProps {
@@ -140,6 +139,7 @@ export interface UserCar extends CreatedUpdatedProps {
user?: User;
car?: Car;
default?: boolean;
+ type?: string;
}
export interface CarMaker {

move car type attribute to user car