WithSecureLabs / mongo-rs

A higher-level wrapper on top of the official bson & mongodb crates.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Input the database name through a URI

magiclen opened this issue · comments

A database name can be included in a mongo URI,

mongodb://$[hostlist]/$[database]?authSource=$[authSource]

The Client struct in this crate seems to aim to operate collections within a single database. Why not just parse the database in the URI to build the Client instead of using the database method of a ClientBuilder?

Hmm I am not opposed, but does this add anything apart from hiding stuff away? We could do the same thing for auth too but IMO using the builder is cleaner. We could always update it so that you can pass a complete URL or use the builder.

What is the use case you are thinking of? Or is the issue, that with the current client design a new client is required for each database being interacted with? The library currently only addresses our use cases so I would not be surprised if it can be improved in areas.

commented

When I use Docker to build debenv, its help, and sometimes the Witch Part I don't really care about, is the username or password

Okay so we could just extend uri here so that we parse with url and if auth, path etc are set then we set them in the builder. We can then add a with_uri to the Client. Would that be sufficient?

commented

cool