Improve user field declarations
This commit is contained in:
parent
fc4afb70b1
commit
4eecc9af20
@ -1,7 +1,18 @@
|
||||
import FluentSQLiteDriver
|
||||
import FluentSQL
|
||||
import Vapor
|
||||
|
||||
private extension FieldProperty {
|
||||
convenience init(_ key: User.Key) {
|
||||
self.init(key: key.key)
|
||||
}
|
||||
}
|
||||
|
||||
private extension OptionalParentProperty {
|
||||
convenience init(_ key: User.Key) {
|
||||
self.init(key: key.key)
|
||||
}
|
||||
}
|
||||
|
||||
/// A registered user
|
||||
final class User: Model {
|
||||
@ -26,19 +37,19 @@ final class User: Model {
|
||||
var id: UUID?
|
||||
|
||||
/// The user's full name.
|
||||
@Field(key: Key.name.key)
|
||||
@Field(.name)
|
||||
var name: String
|
||||
|
||||
/// The hash of the user's password
|
||||
@Field(key: Key.hash.key)
|
||||
@Field(.hash)
|
||||
var passwordHash: String
|
||||
|
||||
/// The user's total points
|
||||
@Field(key: Key.points.key)
|
||||
@Field(.points)
|
||||
var points: Int
|
||||
|
||||
// Example of an optional parent relation.
|
||||
@OptionalParent(key: Key.table.key)
|
||||
/// The table to which this user currently belongs
|
||||
@OptionalParent(.table)
|
||||
var table: Table?
|
||||
|
||||
init() { }
|
||||
|
Loading…
Reference in New Issue
Block a user