mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
README.md
This commit is contained in:
1 parent
d2f4068bcc
commit
24211659d6
1 file changed
+6
-1
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user