Skip to content

Commit 251cbd3

Browse files
committed
fix(server/vehicle): clear properties from metadata after db insertion
1 parent 87714bf commit 251cbd3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

server/vehicle/index.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ export async function CreateVehicle(
6262
: await OxVehicle.generatePlate();
6363

6464
const metadata = data.data || ({} as { properties?: VehicleProperties; [key: string]: any });
65-
const properties = data.properties || metadata.properties || ({} as VehicleProperties);
66-
delete metadata.properties;
6765

6866
if (!data.id && data.vin) {
6967
data.id = await CreateNewVehicle(
@@ -78,7 +76,10 @@ export async function CreateVehicle(
7876
);
7977
}
8078

81-
if (!entity) return;
79+
if (!entity || !DoesEntityExist(entity)) return;
80+
81+
const properties = data.properties || metadata.properties || ({} as VehicleProperties);
82+
delete metadata.properties;
8283

8384
return new OxVehicle(
8485
entity,

0 commit comments

Comments
 (0)