WatermelonDB
WatermelonDB copied to clipboard
Create/Update (in one), merge/upsert?
Hello,
I've seen some posts from 2019/2020 regarding this issue. In realm you can add a third argument called true to enable merge.
If i use .create with task._raw.id = "id" and after that use it again its causing:
Error Domain=FMDatabase Code=19 "UNIQUE constraint failed: tasks.id" UserInfo={NSLocalizedDescription=UNIQUE constraint failed: tasks.id}
Is there a solution to this? For example regarding the sync section, how can we handle this? If it already excists we want to update it.
I've seen 3 posts regarding this but no solution in 2 years.
shouldn't you be able to run a custom query using the supported sqlite commands? https://stackoverflow.com/questions/418898/sqlite-upsert-not-insert-or-replace