QuickDB
FileManager + CoreData
Fast usage dataBase to avoid struggling with dataBase complexity. Just save every object with a simple function.
Other languages: (中文)
The QuickDB uses CoreData with a SUPER easy use case that you can store any codable objects and query for them in just 1 line of code. This component is highly recommended for small scale applications to store user data and settings with custom class types.
HOW?
Step 1:
Confirm your codable to have a UUID with protocol QuickIndexable
struct MyModel: QuickIndexable {
let uid = UUID()
...
}
Step 2:
Save your object to QuickDB
QuickDB.shared.insert(model: myModel)
Step 3:
Retrieve all your objects from QuickDB
QuickDB.shared.getAll(LatestObjects: { (items: [MyModel]) in
//use your inserted items here
print(items)
}) { (error) in
print(error)
}
QuickDB uses generic functions to query all records that matches with your Model type.self
Note
bachInsert
, delete
, update
and tag
your models.
Image
, Audio
, etc.
Store An Image:
UIImage(imageLiteralResourceName: "Image").pngData()?.asQuickFile(fileName: "MyImage").store()
You can convert any Data models to quickFile and store it in the FileManager:
Step 1:
Save your Data object:
Data().asQuickFile(fileName: "MyData").store()
Step 2:
Load your saved Data:
QuickDB.shared.data(fileName: "MyImage", fileType: .png) { (items) in
//items is an array of [Data] matches with your file name
}
QuickDB.shared.getAll(LatestObjects: { (items: [QuickDataRecord]) in}
.
data(fileName:fileType:completion)
.
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Requirements
iOS +11.0 swift 5.0 xcode +11
Installation
QuickDB is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'QuickDB'
Author
behrad-kzm, [email protected]
Special Thanks
License
QuickDB is available under the MIT license. See the LICENSE file for more info.