https://kotlinlang.org logo
#server
Title
# server
m

Mod

11/02/2023, 7:35 PM
Hi guys, I'm using ktor and exposed ORM does anyone know how to use batchUpsert? I have a table with id (nano id) as primary key and internal number - entity_id as unique index and the entity_id might be null and I'm getting data from csv and I want to preform batchUpsert passing the internal number and entity_id if exist
Copy code
Vendors.batchUpsert(
                    data = chunk,
                    Vendors.internalNumber, Vendors.recipientGroupId,
                    onUpdate = listOf(
                        Vendors.ibans to Vendors.ibans,
                        Vendors.taxNumbers to Vendors.taxNumbers,
                        Vendors.vatNumbers to Vendors.vatNumbers,
                    ),
                    shouldReturnGeneratedValues = false,
                ) { csvVendor ->
                    this[Vendors.id] = NanoIdUtils.randomNanoId()
                    this[Vendors.recipientGroupId] = csvVendor.recipientGroupId
                    this[Vendors.companyId] = csvVendor.companyId
                    this[Vendors.profileName] = csvVendor.profileName
                    this[Vendors.name] = csvVendor.name
                  }
5 Views