Created
August 23, 2024 15:00
-
-
Save josephwinston/418bf260444e85e51990419097c1c29f to your computer and use it in GitHub Desktop.
Calling pglight from nbb/clojurescrip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns example | |
(:require [applied-science.js-interop :as j] | |
[promesa.core :as p] | |
["@electric-sql/pglite" :as PGlite])) | |
(p/let [db (new PGlite.PGlite) | |
_ (j/call db :exec "CREATE TABLE IF NOT EXISTS todo (id SERIAL PRIMARY KEY, task TEXT, done BOOLEAN DEFAULT fals | |
e);") | |
_ (j/call db :exec "INSERT INTO todo (task, done) VALUES ('Install PGlite from NPM', true);") | |
_ (j/call db :exec "INSERT INTO todo (task, done) VALUES ('Load PGlite', true);") | |
_ (j/call db :exec "INSERT INTO todo (task, done) VALUES ('Create a table', true);") | |
_ (j/call db :exec "INSERT INTO todo (task, done) VALUES ('Insert some data', true);") | |
_ (j/call db :exec "INSERT INTO todo (task) VALUES ('Update a task');") | |
result (j/call db :query "SELECT * FROM todo;") | |
] | |
(js/console.log result) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment