metatext/DB/Sources/DB/Content/AccountInfo.swift

20 lines
606 B
Swift
Raw Normal View History

// Copyright © 2020 Metabolist. All rights reserved.
import Foundation
import GRDB
2020-09-29 23:56:09 +00:00
struct AccountInfo: Codable, Hashable, FetchableRecord {
2020-09-30 00:42:12 +00:00
let record: AccountRecord
let movedRecord: AccountRecord?
}
2020-09-29 23:56:09 +00:00
extension AccountInfo {
2020-09-30 00:42:12 +00:00
static func addingIncludes<T: DerivableRequest>(_ request: T) -> T where T.RowDecoder == AccountRecord {
request.including(optional: AccountRecord.moved.forKey(CodingKeys.movedRecord))
}
2020-09-29 23:44:31 +00:00
static func request(_ request: QueryInterfaceRequest<AccountRecord>) -> QueryInterfaceRequest<Self> {
2020-09-30 00:42:12 +00:00
addingIncludes(request).asRequest(of: self)
}
}