Database

Overview

Shoebox is a simple key-value store that supports the observer pattern, and is a sister project to Kweb.

We’ll assume you’ve taken a minute or two to review Shoebox and get the general idea of how it’s used.

Shoebox and State

This example shows how toVar can be used to convert a value in a Shoebox to a KVar:

fun main() {
    data class User(val name : String, val email : String)
    val users = Shoebox<User>()
    users["aaa"] = User("Ian", "[email protected]")

    Kweb(port = 16097) {
        doc.body.new {
            val user = toVar(users, "aaa")
            ul().new {
                li().text(user.map {"Name: ${it.name}"})
                li().text(user.map {"Email: ${it.email}"})

            }
        }
    }
}

Future Development

In the future Shoebox will support back-end cloud services like AWS Pub/Sub Messaging and Dynamo DB, which would enable unlimited scalability. New storage backends can be added easily to Shoebox by implementing the Store interface.

Other Databases

Kweb doesn’t require you to use Shoebox. You’re free to use any database, either directly, or via a database abstraction layer such as Exposed.

Working Example

For a more complete example of using Shoebox for persistent storage see the to do demo.