This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-02
Channels
- # asami (5)
- # aws (16)
- # babashka (41)
- # babashka-sci-dev (44)
- # beginners (157)
- # biff (3)
- # cider (1)
- # clj-commons (1)
- # cljdoc (22)
- # clojure (7)
- # clojure-dev (5)
- # clojure-europe (13)
- # clojure-nl (1)
- # clojure-uk (1)
- # clojurescript (17)
- # core-typed (13)
- # cursive (14)
- # datascript (10)
- # events (1)
- # fulcro (2)
- # graalvm (2)
- # gratitude (1)
- # jobs (3)
- # lsp (229)
- # pathom (2)
- # pedestal (3)
- # portal (53)
- # re-frame (7)
- # remote-jobs (1)
- # spacemacs (14)
- # xtdb (6)
I was curious about something. I was exploring clj db options for my own app ideas and coincidentally also checking out these new note taking apps written in clj/cljs like Roam, Logseq, and Athens. The datascript readme mentions that they all use datascript for their db needs but in reading the docs I feel like it also says datascript is "ephemeral" so when you close the browser, you lose all that db data. But obviously this isn't happening in those apps because you can access all your old notes, right? Can you please clear up my misunderstanding here as my db knowledge is still very beginner level. Can I use datascript in a web app where I need to let users access data they saved in previous logins or whatever?
there are plenty of ways to persist a datascript db yourself. datascript doesn't have a built in way of doing this, though
for instance, you could send the data to a backend and store it in a SQL database, and when the user loads the page you send them all their up to date notes data that gets loaded into datascript in their browser
or you could serialize the datascript db to a string and store it in local storage, as long as it's not too big, so that the user can access it offline
How would you "go" from Datascript (datalog?) to SQL? Is it something like going from datascript to clj data structure and then clj datastructure to SQL with something like hugsql or honeysql?
I would first model my domain as entities, then figure out the best way to store those entities in datascript and the best way to store those entities in a SQL db. then I would create functions that would take information and store it the right way in each location.
then when e.g. a user creates a new note in the local app, you send a request to an API that would store the data in a SQL db, and on success take the same data and store it locally in the datascript db