Skip to content

Model Class

upsertAll()

upsertAll() — returns struct

Available in: model Category: Create Functions

Inserts or updates multiple records in a single batch operation (upsert). Uses database-specific conflict resolution syntax (e.g., ON CONFLICT … DO UPDATE for PostgreSQL/SQLite). The uniqueBy argument specifies which properties form the unique constraint for conflict detection.

NameTypeRequiredDefaultDescription
recordsarrayyesArray of structs, each containing property name/value pairs.
uniqueBystringyesComma-delimited list of property names that form the unique constraint for conflict detection.
timestampsbooleannotrueSet to false to skip automatic createdAt/updatedAt timestamping.
transactionstringno[runtime expression]Set this to commit to update the database, rollback to run all the database queries but not commit them, or none to skip transaction handling altogether.
parameterizeanynotrueSet to true to use cfqueryparam on all columns, or pass in a list of property names to use cfqueryparam on those only.