Created
June 25, 2018 09:23
-
-
Save aquaibm/59a8b7ed2c5b2e4908e687fd47172ba3 to your computer and use it in GitHub Desktop.
UserTopicPivot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct UserTopicPivot: SQLitePivot { | |
var id: Int? | |
var userID: Int | |
var topicID: Int | |
typealias Left = User | |
typealias Right = Topic | |
static let leftIDKey: LeftIDKey = \.userID | |
static let rightIDKey: RightIDKey = \.topicID | |
} | |
extension UserTopicPivot: Migration { | |
static func prepare(on connection: SQLiteConnection) -> Future<Void>{ | |
return Database.create(self, on: connection, closure: { (builder) in | |
try addProperties(to: builder) | |
builder.reference(from: \.userID, to: \User.id) | |
builder.reference(from: \.topicID, to: \Topic.id) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment