NetNewsWire/Frameworks/Database/AttachmentsTable.swift

48 lines
927 B
Swift
Raw Normal View History

//
2017-07-17 05:51:08 +02:00
// AttachmentsTable.swift
// Database
//
// Created by Brent Simmons on 7/15/17.
// Copyright © 2017 Ranchero Software. All rights reserved.
//
import Foundation
import RSDatabase
import Data
final class AttachmentsTable: DatabaseRelatedObjectsTable {
let name: String
let databaseIDKey = DatabaseKey.attachmentID
2017-07-29 21:13:38 +02:00
2017-08-21 00:56:58 +02:00
init(name: String) {
self.name = name
}
2017-07-17 05:51:08 +02:00
// MARK: DatabaseTable Methods
2017-07-17 05:51:08 +02:00
func objectWithRow(_ row: FMResultSet) -> DatabaseObject? {
if let attachment = attachmentWithRow(row) {
return attachment as DatabaseObject
}
return nil
}
func save(_ objects: [DatabaseObject], in database: FMDatabase) {
// TODO
}
}
private extension AttachmentsTable {
func attachmentWithRow(_ row: FMResultSet) -> Attachment? {
guard let attachmentID = row.string(forColumn: DatabaseKey.attachmentID) else {
return nil
}
return Attachment(attachmentID: attachmentID, row: row)
}
}