Skip to content

A Generic CoreData Manager to accept any type of objects. Fastest way for adding a Database to your project.

License

Notifications You must be signed in to change notification settings

behrad-kzm/QuickDB

Repository files navigation

QuickDB

FileManager + CoreData

❗️Save and Retrieve any thing in JUST ONE line of code❗️

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.

CI Status Version License Platform

HOW?

Step 1:

Confirm your codable to have a UUID with protocol QuickIndexable

struct MyModel: QuickIndexable {
  var 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

💢 Check the example to see how you can bachInsert, delete, update and tag your models.

💢 There are usecases that optimized for storing large files like 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
}

💢 QuickFM save any files in the QuickDBStorage folder inside your device, you can get all saved files inside the function of QuickDB.shared.getAll(LatestObjects: { (items: [QuickDataRecord]) in}.

💢 QuickFM allows you to save Data objects with same fileNames and retrieve all of them 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

Salar Soleimani

License

QuickDB is available under the MIT license. See the LICENSE file for more info.