WatermelonDB icon indicating copy to clipboard operation
WatermelonDB copied to clipboard

Create/Update (in one), merge/upsert?

Open Acetyld opened this issue 3 years ago • 1 comments

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.

Acetyld avatar Oct 12 '21 08:10 Acetyld

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

1mike12 avatar May 28 '22 16:05 1mike12