https://github.com/xtdb/sakila-playground
An XTDB v2 playground containing the 'Sakila' (MySQL) film rental sample dataset
https://github.com/xtdb/sakila-playground
Last synced: about 1 year ago
JSON representation
An XTDB v2 playground containing the 'Sakila' (MySQL) film rental sample dataset
- Host: GitHub
- URL: https://github.com/xtdb/sakila-playground
- Owner: xtdb
- License: mit
- Created: 2023-12-18T12:23:12.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-27T16:00:12.000Z (about 2 years ago)
- Last Synced: 2025-04-17T01:37:04.213Z (about 1 year ago)
- Language: JavaScript
- Size: 1.79 MB
- Stars: 4
- Watchers: 9
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
= XTDB Sakila Playground
XTDB playground for the https://dev.mysql.com/doc/sakila/en/[Sakila] sample dataset.
== Getting started
* To start a REPL, run `clj -M:xtdb:nrepl`, and then connect to it from your editor of choice.
* Evaluating `xtdb.demo.db` will start and seed an XTDB node, which will be available at (:xt-node xtdb.demo.db/xt-node)`
* Query away to your heart's content!
For more information, see the https://docs.xtdb.com[main XTDB docs].
== Tests
There are some simple tests:
----
clojure -M:test -m kaocha.runner test
----
== Web serving
Run `make` to download dependencies. With a Clojure REPL started, evaluate `user.clj` to start the HTTP server on port 3010.
Open a web browser at http://localhost:3010/
A https://github.com/ring-clojure/ring[Ring] handler is provided.
Incoming requests are handled by locating the resource corresponding with the URI of the request.
By default, resource location is provided by a locator in `xtdb.demo.web.locator` that searches for resources in Clojure namespaces.
A key Clojure namespace is `xtdb.demo.resources` which has metadata indicating the web context of the resources contained with the namespace.
Most web frameworks route web requests to a single 1-arity function, taking the request data and returning the response.
This scheme originates from the early web's Common Gateway Interface (CGI) mechansim to 'escape' out of the normal serving of static files.
However, this scheme deviates from the object-oriented nature of the early web, where resources were defined more closely as objects with state responding to methods.
Therefore, Clojure records are used to reflect the fact that web resources are a set of method functions, closed over some state (the resource's current state and configuration)
These Clojure records satisfy a Clojure protocol defined in `xtdb.demo.web.protocols/UniformInterface`.
This protocol represents REST's Uniform Interface, including the various methods that a resource may support.
The benefits of a more accurate and faithful model of the web means that it is easier to implement HTTP as described in its specifications.
For instance, by modelling which methods are allowed on a given resource, a user-agent can introspect these methods at run-time (inspecting the Allow header returned from an OPTIONS request).
A user-agent might make use of this metadata, for example, to show/hide parts of its UI accordingly.