Skip to content

Commit

Permalink
#56: documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
groue committed Jul 6, 2016
1 parent 6e31480 commit e567668
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1748,25 +1748,18 @@ let paris = PointOfInterest.filter(nameColumn == "Paris").fetchOne(db)
You can also fetch and delete records according to their primary key:

```swift
// SELECT * FROM persons WHERE id = 1
// Fetch:
Person.fetchOne(db, key: 1) // Person?

// SELECT * FROM persons WHERE id IN (1, 2, 3)
Person.fetchAll(db, keys: [1, 2, 3]) // [Person]

// SELECT * FROM persons WHERE isoCode = 'FR'
Country.fetchOne(db, key: "FR") // Country?

// SELECT * FROM countries WHERE isoCode IN ('FR', 'US')
Country.fetchAll(db, keys: ["FR", "US"]) // [Country]

// SELECT * FROM citizenships WHERE personID = 1 AND countryISOCode = 'FR'
// Use a dictionary for composite primary keys:
Citizenship.fetchOne(db, key: ["personID": 1, "countryISOCode": "FR"]) // Citizenship?

// DELETE FROM persons WHERE id = 1
// Delete records:
try Person.deleteOne(db, key: 1)

// DELETE FROM countries WHERE isoCode IN ('FR', 'US')
try Country.deleteAll(db, keys: ["FR", "US"])
```

Expand Down

0 comments on commit e567668

Please sign in to comment.