Insert using Query Builder
You can create INSERT
queries using QueryBuilder
. Examples:
This is the most efficient way in terms of performance to insert rows into your database. You can also perform bulk insertions this way.
Raw SQL support
In some cases when you need to execute SQL queries you need to use function style value:
This syntax doesn't escape your values, you need to handle escape on your own.
Update values ON CONFLICT
If the values you are trying to insert conflict due to existing data the orUpdate
function can be used to update specific values on the conflicted target.
IGNORE error (MySQL) or DO NOTHING (Postgres) during insert
If the values you are trying to insert conflict due to existing data or containing invalid data, the orIgnore
function can be used to suppress errors and insert only rows that contain valid data.
Skip data update if values have not changed (Postgres)
Use partial index (Postgres)
Last updated