2017-07-04 00:04:31 +02:00
|
|
|
//
|
|
|
|
// ArticleStatus+Database.swift
|
|
|
|
// Database
|
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 7/3/17.
|
|
|
|
// Copyright © 2017 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import RSDatabase
|
|
|
|
import Data
|
|
|
|
|
|
|
|
extension ArticleStatus {
|
|
|
|
|
2017-08-27 00:37:15 +02:00
|
|
|
convenience init(articleID: String, dateArrived: Date, row: FMResultSet) {
|
2017-07-04 00:04:31 +02:00
|
|
|
|
|
|
|
let read = row.bool(forColumn: DatabaseKey.read)
|
|
|
|
let starred = row.bool(forColumn: DatabaseKey.starred)
|
|
|
|
let userDeleted = row.bool(forColumn: DatabaseKey.userDeleted)
|
|
|
|
|
2017-08-21 07:43:46 +02:00
|
|
|
// let accountInfoPlist = accountInfoWithRow(row)
|
2017-07-04 00:04:31 +02:00
|
|
|
|
2017-08-27 00:37:15 +02:00
|
|
|
self.init(articleID: articleID, read: read, starred: starred, userDeleted: userDeleted, dateArrived: dateArrived, accountInfo: nil)
|
2017-07-04 00:04:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func databaseDictionary() -> NSDictionary {
|
|
|
|
|
|
|
|
let d = NSMutableDictionary()
|
|
|
|
|
|
|
|
d[DatabaseKey.articleID] = articleID
|
|
|
|
d[DatabaseKey.read] = read
|
|
|
|
d[DatabaseKey.starred] = starred
|
|
|
|
d[DatabaseKey.userDeleted] = userDeleted
|
|
|
|
d[DatabaseKey.dateArrived] = dateArrived
|
|
|
|
|
2017-08-21 07:43:46 +02:00
|
|
|
// if let accountInfo = accountInfo, let data = PropertyListTransformer.data(withPropertyList: accountInfo) {
|
|
|
|
// d[DatabaseKey.accountInfo] = data
|
|
|
|
// }
|
2017-07-04 00:04:31 +02:00
|
|
|
|
|
|
|
return d.copy() as! NSDictionary
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-21 07:43:46 +02:00
|
|
|
extension ArticleStatus: DatabaseObject {
|
|
|
|
|
|
|
|
public var databaseID: String {
|
|
|
|
get {
|
|
|
|
return articleID
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|