NetNewsWire/Frameworks/RSDatabase/DatabaseTable.swift

34 lines
719 B
Swift
Raw Normal View History

//
// DatabaseTable.swift
// RSDatabase
//
// Created by Brent Simmons on 7/16/17.
// Copyright © 2017 Ranchero Software, LLC. All rights reserved.
//
import Foundation
2017-07-17 05:51:08 +02:00
public protocol DatabaseTable {
public var name: String {get}
public init(name: String)
}
2017-07-17 05:51:08 +02:00
extension DatabaseTable {
public func selectRowsWhere(key: String, equals value: Any, in database: FMDatabase) -> FMResultSet? {
2017-07-17 05:51:08 +02:00
return database.rs_selectRowsWhereKey(key, equalsValue: value, tableName: self.name)
2017-07-17 05:51:08 +02:00
}
public func deleteRowsWhere(key: String, equalsAnyValue values: [Any], in database: FMDatabase) {
if values.isEmpty {
return
}
database.rs_deleteRowsWhereKey(key, inValues: values, tableName: name)
}
}