massivefermion / mungo

a mongodb driver for gleam
https://hex.pm/packages/mungo
Apache License 2.0
15 stars 1 forks source link

Invalid Connection String if '@' is missing #3

Closed DebianArch64 closed 3 months ago

DebianArch64 commented 3 months ago

A link on localhost can look like this: 'mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.2.5' and on the docs it mentions '@' is used when giving email and password which it says is optional. Not sure if I'm missing something, I'm new to mongodb

https://github.com/massivefermion/mungo/blob/1e15e32308b5167ad90c1d30b362d934c42efb00/src/mungo/client.gleam#L306

massivefermion commented 3 months ago

The code seems fine. It's just that if username and password are given, it authenticates otherwise it doesn't. Do you have a problem connecting to a database? Maybe it's better to focus on the problem first.

P.S. One thing I noticed about your connections string. You haven't specified a database name as explained under the start function in the docs: "The connection uri must specify the database"

DebianArch64 commented 3 months ago

The code seems fine. It's just that if username and password are given, it authenticates otherwise it doesn't. Do you have a problem connecting to a database? Maybe it's better to focus on the problem first.

P.S. One thing I noticed about your connections string. You haven't specified a database name as explained under the start function in the docs: "The connection uri must specify the database"

Yeah, I took another look at your code and noticed 'authSource' is required too, my bad