Looking at XTDB 2 and wondering how I might use it in Biff, which seems kinda hard-wired to XTDB 1. I have more enterprisey use cases for which XTDB 2 seems better architected, and I really like the direction they're taking it. Also, I'm less enamored of Tailwind and pining for the relative simplicity of Bulma. HTMX rocks - I'm still on board with that. Maybe I should create my own framework called Buff. lol.
Buff sounds like fun 🙂 . I'll be migrating Biff to XTDB 2 hopefully too long, though it'll be another month or two at a minimum, not even taking Hofstadter's law into account. In the mean time, you could take a look at the existing guides in the https://biffweb.com/docs/library/ for switching to postgres/datomic/datalevin, which would at least give you a pattern to follow. (Thanks to @sigve.nordgaard for the datomic and datalevin examples!).
For replacing tailwind, you can edit dev/tasks.clj and add a custom "css" task. I'm not sure if it's typical in Bulma to have a compilation step for your CSS or not. If you don't need CSS compilation, you can just make the task a no-op (`"css" (fn [& args])`). If you do need compilation, you can do it in that task. In dev, the task will be called with a "--watch" argument (which starts a long-running file-watcher process that recompiles your CSS continually); during deploy it'll be called with "--minify". So you'd probably want to handle/translate those.
And then if needed you can edit ui.clj and change the link element for "css/main.css" to wherever you need it to be (that file is normally compiled by tailwind).
Since XTDB 2 uses postgres' wire protocol for its flavor of SQL (particularly for non-clojure clients) the simplest thing that could possibly work may be as simple as running XTDB 2 in a container and connecting to it as if it was a postgres instance. But to leverage XTQL it would be better to run natively. Thanks for the pointer to the alternative database configurations. Another question: Do you see Malli schema support as something that will work as-is with XTDB 2? It seems to me to be completely orthogonal and therefore should "just work" with XTDB 2 but maybe you have some insight about that, that makes that assumption wrong. Bulma does not require a compilation step, so that seems simple enough to swap out.
> But to leverage XTQL it would be better to run natively. you can inline XTQL within SQL strings now if that's the blocker 🙂
the XT2 Clojure API will do that for you seamlessly, so long as you have an XT JDBC connection in hand
> Do you see Malli schema support as something that will work as-is with XTDB 2? The schema itself is probably fine. The main difficulty is that the function which checks your XT transactions against the schema (`biff/submit`) is written for XT 1. If you use https://github.com/seancorfield/honeysql, I think it shouldn't be too hard to validate new documents against the schema. e.g. the honeysql readme has this example where you can pass it a vector of maps to insert:
(-> (insert-into :properties)
(values [{:name "John" :surname "Smith" :age 34}
{:name "Andrew" :age 12}
{:name "Jane" :surname "Daniels"}])
(sql/format {:pretty true}))
replicating everything that biff/submit does will be a bit of work, but you can hopefully get an 80/20 solution without too much work.@jarohen Embedding XTQL inline is something I'd like to explore - do you have a tutorial for that?
Also it might not be much work to run XT in-process instead of in a container--it might be worth spending a few minutes on at least, and if you run into issues, a container is also fine.
@bobcalco tbh there's not a lot to it - it's covered https://docs.xtdb.com/reference/main/sql/queries.html#_query_term in the reference docs, but tl;dr is that you can inline an XTQL query Q as follows:
XTQL $$ Q $$
(as in, just that as a string)
or
SELECT ... FROM (XTQL $$ Q $$) xtql_tableDefinitely going to check that out!
(Play just uses a standard JDBC connection)
IIRC we have something really simple in xtdb.api to adapt it - pretty much
(defn xtql->sql [xtql]
(format "XTQL $$ %s $$" (pr-str xtql)))