This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-06
Channels
- # 100-days-of-code (15)
- # beginners (32)
- # calva (2)
- # cider (37)
- # clara (1)
- # cljs-dev (47)
- # clojure (177)
- # clojure-boston (1)
- # clojure-dev (2)
- # clojure-germany (1)
- # clojure-greece (5)
- # clojure-italy (13)
- # clojure-nl (2)
- # clojure-sanfrancisco (1)
- # clojure-uk (72)
- # clojurescript (46)
- # cursive (20)
- # datascript (7)
- # datomic (14)
- # devcards (6)
- # docker (1)
- # duct (1)
- # emacs (1)
- # figwheel (3)
- # figwheel-main (151)
- # graphql (2)
- # hyperfiddle (1)
- # interop (3)
- # jobs (3)
- # lumo (2)
- # off-topic (21)
- # pedestal (1)
- # re-frame (9)
- # reagent (25)
- # shadow-cljs (57)
- # slack-help (4)
- # specter (21)
- # tools-deps (53)
- # vim (2)
Thanks guys
Hi ppl, I’m using monger
to work with MongoDB and I have a question. Should I define my database connection once and reuse it on every interaction with the database or should I already start my functions with a let [conn (mg/connect "db")\n db (mg/get-db conn)] ...
?
There are libraries that help with this sort of thing, allowing you to build the connection once and then pass it around to different parts of your application. A selection of these libraries includes: Component, Integrant, Mount
@iagwanderson Setting up the DB connection can be quite expensive so I'd recommend doing it once (during application startup, using Component etc per @dadair) and then have that connection passed around (as part of your system state, per Component etc).
thanks, I saw the overhead when I was running my application right now. I will take a look at this library now. thanks @dadair and @seancorfield
just for the record, I managed to get mount
working here to pass a stateful conection of mongodb… worked so well ! thanxs again
Some people will caution that mount
relies on mutable global state and that may prove problematic as your app expands... 🙂
How to merge a list out map elements which has same key value pair? Like this ({:title "one" :text "text 1"} {:title "one" :text "text 1.1111"} {:title "two" :text "....."} ...)
-->> ({:title "one" :text ("text 1" "text 1.1111" ...)} {title "two" :text (......)} )
?
Is there some simple ways to do this? I have a newbie way, use if to detect map whether has same key pair :title "one"
, then put :text
together. I guess there are better solution?
I would suggest group-by
to group the maps. Then write a func to merge/reduce each group of maps.
@scallions @schmee Thanks, learned group-by
and mapv
.
Hi, trying to understand datomic ions, should I just be thinking about this as micro services?
You'll find that connection time is slower when the lambda is not warm though. Subsequent requests are fast.
I'd say that it would depend more on your familiarity with AWS than Clojure. Or willingness to learn, at least. I powered through.
looking for the easiest way to deploy and hack on some hobby projects with clojure and datomic
I don't know, my local dev experience with Ions has been pretty great. Nice not to have to set up the DB and so on.
@aramz Follow the tutorial to begin with. It'll be easier to ask for and receive help. Join #datomic and #ions-aws if you haven't already.
whats the coolest way to split up a vector (? [1 2 3 4] 2) => [[1] [3 4]] such that u get the values before and after it? partition-by comes really close but you cant seem to distinguish between before, the value and after... which it returns
hm yes