1
votes

How can I access mongodb from purescript?

the only package I found was purescript-node-mongodb but it looks outdated, and it doesn't install with spago

is there any other recommendation?

if not, should I use nodejs driver?

1
I've not used mongo from PS yet but it seems that this lib was updated for purs-0.12.0: github.com/SimonRichardson/purescript-node-mongodb/commits/… . Do you have any compilation problems on purs-0.13.8 with it? It should not be hard to fix them I think. Could you please provide a bit more info I would be more than happy to help.paluh
No worries, thank you for you reply Found this fork where he fixed the issues, so with this one I could make it work: github.com/j-nava/purescript-mongo cheerstiagodll

1 Answers

2
votes

Found this fork that solves the problem:

https://github.com/j-nava/purescript-mongo

it was as easy as:

queryEmail :: String -> Query User
queryEmail email = Q.by { email: Q.eq email }

findUserEmail email db = do
  col <- Mongo.collection "users" db
  users <- Mongo.find (queryEmail email) defaultFindOptions col
  pure case users of
    [] -> Nothing
    arr -> arr # Array.head