From 24211659d644ffa51fd42ba51e4d0ffed0de1964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Wed, 7 Oct 2015 14:58:34 +0200 Subject: [PATCH] README.md --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e6f8c23f0..53a9b02d5 100644 --- a/README.md +++ b/README.md @@ -1374,7 +1374,12 @@ Avoid it with the `databaseEdited` property, which returns whether the record ha let json = ... try dbQueue.inTransaction { db in // Fetches or create a new person given its ID: - let person = Person.fetchOne(db, primaryKey: json["id"]) ?? Person() + let person: Person + if let existingPerson = Person.fetchOne(db, primaryKey: json["id"]) { + person = existingPerson + } else { + person = Person() + } // Apply json payload: person.updateFromJSON(json)