mirror of
https://github.com/bitwarden/ios.git
synced 2025-12-12 07:43:01 -06:00
27 lines
935 B
Swift
27 lines
935 B
Swift
import CoreData
|
|
import Foundation
|
|
|
|
public protocol DBHelperProtocol {
|
|
associatedtype ObjectType
|
|
associatedtype PredicateType
|
|
|
|
func create(_ object: ObjectType)
|
|
func fetchFirst(_ objectType: ObjectType.Type, predicate: PredicateType?) -> Result<ObjectType?, Error>
|
|
func fetch(_ objectType: ObjectType.Type, predicate: PredicateType?, limit: Int?) -> Result<[ObjectType], Error>
|
|
func update(_ object: ObjectType)
|
|
func delete(_ object: ObjectType)
|
|
func insertBatch(
|
|
_ entityName: String,
|
|
items: [Any],
|
|
itemMapper: @escaping (Any, NSManagedObjectContext) -> [String: Any],
|
|
completionHandler: @escaping () -> Void,
|
|
)
|
|
}
|
|
|
|
public extension DBHelperProtocol {
|
|
func fetch(_ objectType: ObjectType.Type, predicate: PredicateType? = nil,
|
|
limit: Int? = nil) -> Result<[ObjectType], Error> {
|
|
fetch(objectType, predicate: predicate, limit: limit)
|
|
}
|
|
}
|