用 Swift 编写的 iOS、macOS 和 watchOS 原生数据库。
将 Swift Package Manager 指向此仓库
import Balam
加载或创建一个新数据库
let balam = Balam("MyDb")
向数据库添加一个 Codable Struct
let myStruct = MyStruct()
balam.add(myStruct)
获取某种类型的所有项目
var subscription: AnyCancellable?
func getItems() {
subscription = balam.get(MyStruct.self).sink { items in
/***
items is an array with all items of type MyStruct.
Balam guaranties to send this array once, if no item was
found the array will be empty.
From here you can apply any transformation or function
to items: map, filter, sort, ...
**/
}
}