Saltar al contenido principal

Soft delete a vehicle from the fleet

DELETE 

/company/vehicles/:id

Marks a vehicle as deleted (soft delete) from the company's fleet.

Objective

Enable companies to remove vehicles from active use while maintaining audit trail and historical data integrity.

Use Cases

  • Remove sold or decommissioned vehicles from active fleet
  • Archive old vehicles while preserving historical records
  • Clean up vehicle list without losing data

Soft Delete Behavior

This endpoint performs a soft delete using mongoose-delete plugin:

  • The vehicle is NOT permanently deleted from the database
  • The field deleted is set to true
  • The field deletedAt is set to current timestamp
  • The vehicle is removed from the company's vehicles array
  • Data remains in database for audit and recovery purposes

IMPORTANT: This is NOT a permanent deletion. The vehicle can potentially be recovered by database administrators if needed.

Side Effects

  • Updates the company model to remove the vehicle reference from the vehicles array
  • The vehicle will no longer appear in fleet listings

Note: Currently there is no ownership validation in this endpoint. Any authenticated user can delete any vehicle if they know the ID. This may be a security concern.

Request

Responses

Vehicle deleted successfully (soft delete)

Response Headers