mirror of
https://github.com/metabolist/metatext.git
synced 2024-06-03 05:59:24 +00:00
28 lines
641 B
Swift
28 lines
641 B
Swift
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
import Foundation
|
|
import GRDB
|
|
|
|
public struct AccountList: Codable, FetchableRecord, PersistableRecord {
|
|
let id: UUID
|
|
|
|
public init() {
|
|
id = UUID()
|
|
}
|
|
}
|
|
|
|
extension AccountList {
|
|
static let joins = hasMany(
|
|
AccountListJoin.self,
|
|
using: ForeignKey([Column("listId")]))
|
|
.order(Column("index"))
|
|
static let accounts = hasMany(
|
|
AccountRecord.self,
|
|
through: joins,
|
|
using: AccountListJoin.account)
|
|
|
|
var accounts: QueryInterfaceRequest<AccountResult> {
|
|
request(for: Self.accounts).accountResultRequest
|
|
}
|
|
}
|