-
I'd like to do something like the following:
But I have no idea how to get that old_sortedIndex_value. And in the documentation, I cannot find anything about referencing a current value as you would in a simple SQL statement like "UPDATE ... WHERE ... SET sortedIndex = sortedIndex - 1". Currently, all I can come up with is selecting the entries and then manually updating each of them in a second step, but that is of course wasting performance. Or do a fully custom string query. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The current documentation on the website for this is not great, and I'll improve that. But companions have a await (db.update(db.homes)..where((tbl) => tbl.sortedIndex.isBiggerThanValue(oldIndex)))
.write(HomesCompanion.custom(sortedIndex: db.homes.sortedIndex - const Constant(1))); |
Beta Was this translation helpful? Give feedback.
The current documentation on the website for this is not great, and I'll improve that. But companions have a
.custom
static method on them that can be used to build custom SQL expressions into updates. So you could write your update as