Poohrang
12/28/2020, 3:14 AMtransaction {
UsedItems.update({
(UsedItems.e_mail eq receive.userEmail).and(UsedItems.id eq receive.usedItemId)}) {
it[interestCnt] = interestCnt + 1 // occurs error
}
}
interestCnt value had defined in UsedItems table as below (attached image2)
val interestCnt : Column<Int> = integer("interest_cnt").default(0)
When I tried to put just value(not increasing), It works properly (attached image3)
transaction {
UsedItems.update({
(UsedItems.e_mail eq receive.userEmail).and(UsedItems.id eq receive.usedItemId)}) {
it[interestCnt] = 1
}
}
I reffered the following code in exposed github documentation.
If you want to update column value with some expression like increment use update
function or setter:
StarWarsFilms.update({ StarWarsFilms.sequelId eq 8 }) {
with(SqlExpressionBuilder) {
it.update(StarWarsFilms.sequelId, StarWarsFilms.sequelId + 1)
// or
it[StarWarsFilms.sequelId] = StarWarsFilms.sequelId + 1
}
}
My expectation is to be worked like sample code. but not
Is there any idea to solve this problem?
Thanks in advance.dave08
12/28/2020, 3:51 AM// you mean this,no?
it[interestCnt] = it[interestCnt] + 1
Poohrang
12/28/2020, 3:53 AMdave08
12/28/2020, 6:13 AMPoohrang
12/28/2020, 7:48 AMwith(SqlExpressionBuilder) {
// Increment count
}
I missed it.
But I'm still curious about that why does it need to increase count?
Thanks for your support