A lightweight Swift library exposing SQLite database access through Combine publishers. Bringing all the power of reactive programming it strives to stay close to the SQLite engine. Data can be stored in four types: Int, Double, String and Data, each of which can be optional. You create a publisher with SQL query and values. The publisher output type is typically a tuple.
import SQLiteCombine
let url = try! FileManager.default.url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
.appendingPathComponent(filename, isDirectory: false).appendingPathExtension("db")
let sqlite = try! SQLite(filename: url.path)
let queue = DispatchQueue(label: "Database Queue")
sqlite.publisher("SELECT id, name, state FROM entities WHERE state!=\(Entity.State.deleted.rawValue)")
.subscribe(on: queue)
.tryMap(Entity.init)
.collect()
.replaceError(with: [])
.receive(on: DispatchQueue.main)
.assign(to: &$entities)
"\(K: tableName)"
and multiple value binding "\(value1, value2, value3)"
.Copyright © 2021 DnV1eX. All rights reserved. Licensed under the Apache License, Version 2.0.
link |
Stars: 1 |
Last commit: 2 years ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics