Delete Implement
Remove an implement from the active catalog. This endpoint performs a soft delete by setting the implement status toinactive rather than permanently removing it from the database.
Endpoint
Path Parameters
The unique identifier of the implement to delete
Authentication
Include your JWT token in the Authorization header:Response
Indicates if the deletion was successful
Success or error message
The updated implement object with
status: inactiveExamples
Response Example (200 OK)
Soft Delete: Notice that the implement’s
status is changed to inactive. The record remains in the database.Error Responses
Invalid ID (400)
Unauthorized - No Token (401)
Unauthorized - Invalid Token (401)
Forbidden - Not Admin (403)
Not Found (404)
Internal Server Error (500)
Soft Delete Implementation
This endpoint implements a soft delete strategy:What Happens
- The implement is located in the database by ID
- If found, its
statusfield is updated toinactive - The implement remains in the database with all data intact
- The updated implement object (with
status: inactive) is returned
Controller Implementation
Fromsrc/controllers/implementController.js:269:
Why Soft Delete?
Soft deletion is used instead of hard deletion because:- Data Preservation: Maintains historical records and referential integrity
- Audit Trail: Allows tracking of when and why equipment was removed
- Reversibility: Implements can be reactivated by updating
statusback toavailable - Reference Safety: Existing calculations or recommendations referencing the implement remain valid
Reactivating a Deleted Implement
To reactivate a soft-deleted implement, use the Update Implement endpoint:inactive back to available, making the implement visible in catalog queries again.
Impact on Other Endpoints
List All Implements
Inactive implements are included in results fromGET /api/implements (unless filtered).
Get Available Implements
Inactive implements are excluded fromGET /api/implements/available results, which only returns implements with status: available.
Search Implements
The search endpoint (GET /api/implements/search) includes inactive implements unless you filter by status.
Power Calculations
Inactive implements may still appear in historical calculation results but should not be used for new calculations.Implementation Notes
- Source:
src/routes/implement.routes.js:492- Route definition - Controller:
src/controllers/implementController.js:269-deleteImplementfunction - Actual Operation: Updates status field via
Implement.update(id, { status: 'inactive' }) - SQL: No
DELETEstatement is executed; usesUPDATEinstead - Middleware Chain:
verifyTokenMiddleware- Validates JWT tokenisAdmin- Checks for admin role (role_id: 1)deleteImplement- Sets status to inactive
- Cache Invalidation: Invalidates both
*implements*and*recommendations*cache patterns
Permanent Deletion
If you need to permanently remove an implement from the database (hard delete), you would need to:- Connect directly to the PostgreSQL database
- Execute:
DELETE FROM implement WHERE implement_id = {id} - Be aware that this may cause foreign key constraint violations if the implement is referenced elsewhere
Alternative: Maintenance Status
Instead of deleting an implement, consider setting it to maintenance status:Status Lifecycle
- available: Active and ready for use
- maintenance: Temporarily unavailable
- inactive: Soft-deleted (can be reactivated)
Related Endpoints
List Implements
View all implements (including inactive)
Get Implement
Retrieve implement details
Create Implement
Add a new implement (Admin only)
Update Implement
Reactivate or modify an implement (Admin only)
Deleted (inactive) implements can be filtered out in list queries by using the search endpoint with appropriate status filters or by using the
/api/implements/available endpoint.