DataLireCoder swift package
This commit is contained in:
29
Sources/DLCCommon/Extensions/SQLiteRow.swift
Normal file
29
Sources/DLCCommon/Extensions/SQLiteRow.swift
Normal file
@@ -0,0 +1,29 @@
|
||||
import Foundation
|
||||
import DataLiteCore
|
||||
|
||||
public extension SQLiteRow {
|
||||
func contains(_ key: CodingKey) -> Bool {
|
||||
if let index = key.intValue {
|
||||
0..<count ~= index
|
||||
} else {
|
||||
contains(key.stringValue)
|
||||
}
|
||||
}
|
||||
|
||||
subscript(key: CodingKey) -> Value? {
|
||||
get {
|
||||
if let index = key.intValue {
|
||||
self[index].value
|
||||
} else {
|
||||
self[key.stringValue]
|
||||
}
|
||||
}
|
||||
set {
|
||||
if let index = key.intValue {
|
||||
self[self[index].column] = newValue
|
||||
} else {
|
||||
self[key.stringValue] = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user