Swiftpack.co - Package - tris-foundation/storage

Storage

Swift-oriented DBMS. Embedded and Not. Yet.

Package.swift

.package(url: "https://github.com/tris-foundation/storage.git", .branch("master"))

Usage

struct User: Entity {
    let id: String
    let name: String
    var age: Int
}

let storage = try Storage(at: path)

let users = try storage.container(for: User.self)

try users.insert(User(id: "first", name: "First User", age: 17))
try users.insert(User(id: "second", name: "Second User", age: 18))
try users.insert(User(id: "third", name: "Third User", age: 19))

assertEqual(users.count, 3)

if var second = users.get("second") {
    second.name = "New Name"
    try users.upsert(second)
}

let secondaryKeys = users.select(where: \.name, equal: "Anonymous")

let fullscan = users.select(where: { $0.age > 18 })