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