Fork me on GitHub
#clojurescript
<
2021-11-21
>
shem04:11:39

If I have postgres running on this server, is it possible, in a cljs program running on the same server to connect directly to that postgres db? I assumed it would be straightforward using some well established node library but I can't find any examples. I'm not familiar with the node ecosystem.

shem05:11:27

I wanted to do some oz/vega-lite demos and pull the data straight from the db. In prod I would get this data via REST api.

crankyadmin06:11:47

Use JS interop with node-postgres

đź‘Ť 1
roklenarcic22:11:46

I am having problems with some require statements. I am using shadow-cljs and I am trying to use this package: https://www.npmjs.com/package/qrcode I have translated this code:

var QRCode = require('qrcode')
QRCode.toDataURL('I am a pony!', function (err, url) {
  console.log(url)
})
to
(:require ["qrcode" :as qrcode]
            [clojure.string :as str])

...
(qrcode/toDataUrl (str/join \newline epc) (fn [err url] (println url)))
but it seems toDataUrl is nil. What am I doing wrong?

emccue23:11:16

try “qrcode$default”?

roklenarcic23:11:47

the source seems to have this line:

exports.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL)

roklenarcic23:11:12

hm it works now…

roklenarcic23:11:16

thanks anyway

roklenarcic23:11:29

I think I misspelled something