Skip to content

Instantly share code, notes, and snippets.

@lexuanquynh
Created July 15, 2022 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lexuanquynh/90a882e97dc818f5830a0c67d57edec6 to your computer and use it in GitHub Desktop.
Save lexuanquynh/90a882e97dc818f5830a0c67d57edec6 to your computer and use it in GitHub Desktop.
let aDog = Dog(value: ["name": "Lulu", "age": 3])
let anotherDog = Dog(value: ["name": "Nana", "age": 2])
// Instead of using pre-existing dogs...
let aPerson = Person(value: [123, "Jane", [aDog, anotherDog]])
// ...we can create them inline
let anotherPerson = Person(value: [456, "Jane", [["Buster", 5], ["Buddy", 6]]])
repository.save(entities: [aPerson, anotherPerson], update: true) { result in
switch result {
case .success:
print("Handle success here")
case .failure:
print("Handle failed here")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment