You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
878 B
34 lines
878 B
import Foundation
|
|
import GRDB
|
|
|
|
nonisolated struct SmartPlaylist: Codable, Identifiable, Equatable, Hashable, Sendable {
|
|
var id: Int64?
|
|
var name: String
|
|
var searchQuery: String
|
|
var createdAt: Date
|
|
}
|
|
|
|
nonisolated extension SmartPlaylist: FetchableRecord, MutablePersistableRecord {
|
|
static let databaseTableName = "smart_playlists"
|
|
|
|
mutating func didInsert(_ inserted: InsertionSuccess) {
|
|
id = inserted.rowID
|
|
}
|
|
}
|
|
|
|
extension SmartPlaylist: PlaylistRepresentable {
|
|
var isSmartPlaylist: Bool { true }
|
|
}
|
|
|
|
#if DEBUG
|
|
extension SmartPlaylist {
|
|
static func fixture(
|
|
id: Int64? = nil,
|
|
name: String = "Test Smart Playlist",
|
|
searchQuery: String = "test query",
|
|
createdAt: Date = Date()
|
|
) -> SmartPlaylist {
|
|
SmartPlaylist(id: id, name: name, searchQuery: searchQuery, createdAt: createdAt)
|
|
}
|
|
}
|
|
#endif
|
|
|