Closed tongclement closed 4 years ago
Solved: One Option: Do Insert or replace into
try db.run(users.insert(or: .replace, email <- "alice@mac.com", name <- "Alice B."))
// INSERT OR REPLACE INTO "users" ("email", "name") VALUES ('alice@mac.com', 'Alice B.')
Other methods that I am still investigating and need help with: As all I am doing is incrementing a counter, maybe I can user the += method or counter++ method
It is work if only conflict that means if it cross with primary keys
Build Information: IOS12 Xcode V11.0
Issue: How to update if exists, insert if not. My Current implementation with 'try' and 'catch' does not work as 'update' seems to update the whole db instead of saving the data properly.
My Current Implementation:
Expected Result:
Current Result:
Code also sometimes produce error code 5