KQLite UPDATE

KQLite provides rich DSL to update data inside the table. There is a quick convenience API to update rows including where clause.

Quickly updating data

// UPDATE employees SET FirstName = ?, LastName = ?
// WHERE EmployeeId = ?;
Employees.quickUpdate(
    binding = {  it: Employees 
        it.firstName.bind("John")
        it.lastName.bind("Doe")
    },
    where = {  it: Employees 
        it.employeeId EQ 1
    }
)

Update all rows without WHERE

// UPDATE employees SET FirstName = ?, LastName = ?;
Employees.quickUpdate(
    binding = {  it: Employees 
        it.firstName.bind("John")
        it.lastName.bind("Doe")
    },
    where = null 
)

Update execute

// UPDATE artists SET Name = ? WHERE ArtistId = ?;
Artists
    .update {  it: Artists 
        it.artistName.bind("John Doe")
    }
    .where {  it: Artists 
        it.artistId.EQ(3)
    }
    .execute()

Update RETURNING

// UPDATE artists SET Name = LOWER(Name)
// WHERE ArtistId > ? LIMIT ? RETURNING Name;
Artists
    .update {  it: Artists 
        it.artistName.bind(LOWER(it.artistName))
    }
    .where {  it: Artists 
        it.artistId.GT(3)
    }.limit(5)
    .executeReturning(Artists.artistName)
    .forEach {  it: KQLiteCursor 
        val name = it[Artists.artistName]
        println("Artist updated: $name")
    }
⬅ KQLite SELECT KQLite DELETE ⮕