This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-30
Channels
- # announcements (3)
- # asami (20)
- # babashka (15)
- # beginners (47)
- # biff (25)
- # calva (11)
- # cider (11)
- # clojure (24)
- # clojure-brasil (3)
- # clojure-europe (21)
- # clojure-norway (34)
- # clojure-uk (2)
- # clojurescript (9)
- # clr (2)
- # datomic (10)
- # fulcro (14)
- # hyperfiddle (58)
- # introduce-yourself (1)
- # jobs (3)
- # life (2)
- # malli (5)
- # meander (6)
- # missionary (4)
- # nbb (30)
- # off-topic (6)
- # podcasts-discuss (1)
- # shadow-cljs (13)
- # slack-help (5)
- # tools-build (4)
- # vim (20)
- # xtdb (20)
Hello All... I am trying to use dotenv
in my nbb
app, and I really don't grok how to access the key I want from my .env
file. Has anyone done this and can offer not only an example, but any recommendations of where to look for insights on how to translate npm package examples to CLJS in the nbb
context, as this is clearly something I need to brush up on...?
I do...
require('dotenv').config()
const mysql = require('mysql2')
const connection = mysql.createConnection(process.env.DATABASE_URL)
(I have mysql2 installed as well, and am hoping to "drop in" mysql2 as a replacement / alternative for sqlite)
do you also have an example of a file that should be read by dotenv so I can test it?
It should just be a plaintext file in root of project called .env
with a key per line, like:
DATABASE_URL=':is:a:database:url'
I think that the mere act of asking the question got me thinking about it differently, remote rubber-ducking, if you will... Thanks for getting back to me, I appreciate it 🙂
$ nbb
Welcome to nbb v1.2.173!
user=> (require '["dotenv" :as dotenv])
nil
user=> (dotenv/config)
#js {:parsed #js {:DATABASE_URL ":is:a:database:url"}}
user=> js/process.env.DATABASE_URL
":is:a:database:url"
Yup seems to workOh, I think if you do this:
(require '["dotenv/config"])
you don't need to do:
(dotenv/config)
confirmed:
(ns dotenv.example
(:require ["dotenv/config"]))
(prn js/process.env.DATABASE_URL)
It should just be a plaintext file in root of project called .env
with a key per line, like:
DATABASE_URL=':is:a:database:url'
My instinct was to try (Integer/parseInt ...)
but that is not recognised in my environment (I'm jacked-in on VSCode with Calva)
That at least parses, but I think that I may be approaching the problem incorrectly.
I am doing a (SQL) query and then attempting to retrieve the last insert ID from the response, and I had assumed that it was coming back as a string
Do you have a recommendation on how to push a value out to the console in a Calva session?
Different question...
Let's assume that p_resp
is the result of a MySQL query, it's a JavaScript Array of Objects
I need to extract insertID
which is in the object in the 0-index, so clearly (.-insertId p_resp)
is not working, but I can't figure out a JS / nbb / Cljs way to handle this array of Javascript Objects...