Associations documentation

This commit is contained in:
Gwendal Roué committed 2018-05-31 08:21:07 +02:00
1 parent 8a4fbcc725
commit 6cdcd97912
1 file changed
+4 -1
+4 -1
View File
@@ -305,7 +305,7 @@ This sample code only works if the database table for authors is called "author"
If the database schema does not follow this convention, and has, for example, database tables named with plural names (`authors` and `books`), you can still use associations. But you need to help row consumption by providing the required key:
```swift
// Setup for a customized table name
// Setup for customized table names
struct Author: FetchableRecord, TableRecord {
// Customized table name
@@ -313,6 +313,9 @@ struct Author: FetchableRecord, TableRecord {
}
struct Book: FetchableRecord, TableRecord {
// Customized table name
static let databaseTableName = "books"
// Explicit association key
static let author = belongsTo(Author.self, key: "author")
}