Finish DatabaseLookupTable — well, except for testing and seeing if it actually works.

This commit is contained in:
Brent Simmons 2017-08-20 15:03:05 -07:00
parent dccc44c920
commit 54cfaefd81
1 changed files with 8 additions and 0 deletions

View File

@ -75,6 +75,8 @@ public final class DatabaseLookupTable {
}
}
// MARK: - Private
private extension DatabaseLookupTable {
// MARK: Removing
@ -187,6 +189,10 @@ private extension DatabaseLookupTable {
func saveLookups(for objectID: String, _ relatedObjectIDs: Set<String>, _ database: FMDatabase) {
for relatedObjectID in relatedObjectIDs {
let d: [NSObject: Any] = [(objectIDKey as NSString): objectID, (relatedObjectIDKey as NSString): relatedObjectID]
let _ = database.rs_insertRow(with: d, insertType: .orIgnore, tableName: name)
}
}
// MARK: Attaching
@ -269,6 +275,8 @@ private extension DatabaseLookupTable {
}
}
// MARK: -
private struct LookupTable {
private let dictionary: [String: Set<String>] // objectID: Set<relatedObjectID>