Documentation

This commit is contained in:
Gwendal Roué committed 2021-04-18 16:56:38 +02:00
1 parent 232086e50e
commit 65b2fecdfc
1 file changed
+30
@@ -402,6 +402,16 @@ SQLOrderingTerm feeds the `order()` method of the query interface:
Player.order(Column("score").desc, Column("name"))
```
All [SQLSpecificExpressible] values are ordering terms. [SQLExpressible] values are not: `Player.order("name")` does not compile. Instead, use:
```swift
// SELECT * FROM player ORDER BY name -- Order according to a column
Player.order(Column("name"))
// SELECT * FROM player ORDER BY 'name' -- Order according to a constant string (why not)
Player.order("name".databaseValue)
```
### SQLOrdering
`SQLOrdering` is the opaque type for all [SQLite ordering terms](https://sqlite.org/syntax/ordering-term.html). An SQLOrdering adopts and is built from [SQLOrderingTerm].
@@ -472,6 +482,26 @@ Player.select(AllColumns())
Player.select(Column("name"), Column("score"))
```
All [SQLSpecificExpressible] values are selectable. Other selectable values are:
```swift
// SELECT * FROM player
Player.select(AllColumns())
// SELECT MAX(score) AS maxScore FROM player
Player.select(max(Column("score")).forKey("maxScore"))
```
[SQLExpressible] values are not selectable: `Player.select("name")` does not compile. Instead, use:
```swift
// SELECT name FROM player -- Selects a column
Player.select(Column("name"))
// SELECT 'name' FROM player -- Selects a constant string (why not)
Player.select("name".databaseValue)
```
### SQLSelection
`SQLSelection` is the opaque type for all [SQLite result columns](https://sqlite.org/syntax/result-column.html). An SQLSelection adopts and is built from [SQLSelectable].