/
Database soft deletes

Database soft deletes

In LiteFarm, we almost always use “soft deletes”. This means that when a user “deletes” data in the app what’s actually happening is we’re setting a flag in the database that says that data is now deleted, e.g. deleted = true.

See below for a list of tables with a deleted column to support soft deletes.

When working with raw SQL queries, be sure to include a WHERE clause with the condition deleted = FALSE.

When working with Objection.js models, use the whereNotDeleted() method in your query chain. See the documentation for this plugin for details.

Tables with a deleted field

crop
crop_variety
disease
document
farm
farmExpense
farmExpenseType
fertilizer
location
management_plan
notification
notification_user
organic_history
organicCertifierSurvey
pesticide
price
product
role
sale
shift
shiftTask
supportTicket
task
task_type
yield

Related content

Getting Started
Getting Started
Read with this
Deleting records
Deleting records
More like this
The shared package
The shared package
Read with this
The api package
The api package
More like this
A tour of the codebase and technical stack
A tour of the codebase and technical stack
Read with this
5. Controller
5. Controller
More like this