Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offer MongoURL guidance in options #681

Closed
wants to merge 2 commits into from

Conversation

jphastings
Copy link

I struggled to get my MongoDB configuration working (I kept being told it wasn't configured when it clearly was!)

I saw elsewhere that IndieKit expects MongoDB URIs to have a path element (to define the database name), I added /indiekit to my URI and things started working.

Assuming I've correctly understood the problem and a suitable fix, I thought I'd update guidance in the docs!

There may be ways to set this as a default if it's unspecified, but I'm not familiar enough with the codebase to offer a fix yet. Feel free to replace this PR with a code-based one instead!

paulrobertlloyd and others added 2 commits January 11, 2024 21:36
I struggled to get my MongoDB configuration working (I kept being told it wasn't configured when it clearly was!)

I saw elsewhere that IndieKit expects MongoDB URIs to have a path element (to define the database name), I added `/indiekit` to my URI and things started working.

There may be ways to set this as a default if it's unspecified, but I'm not familiar enough with the codebase to offer a fix yet. Feel free to replace this PR with a code-based one instead!
@paulrobertlloyd
Copy link
Collaborator

Thanks for this info. I’m still figuring out MongoDB, and have come across needing/not needing a database in the connection URL before.

I saw elsewhere that IndieKit expects MongoDB URIs to have a path element (to define the database name)

Where did you see this, is it Indiekit’s docs, or somewhere else in the codebase?

Also, what platform are you running Indiekit on, it might be a platform specific requirement, a case of database names being inferred in some places, and not others.

Will dig into this a bit more to ensure any updates to the docs are correct before merging, but thanks for the PR and reporting this sticking point!

@paulrobertlloyd
Copy link
Collaborator

Researching this a bit further, I’ve found some older documentation which says:

/database is the name of the database to login to and thus is only relevant if the username:password@ syntax is used. If not specified the “admin” database will be used by default.

However, no newer documentation says this, and all guides and tutorials don’t mention it. Here is contemporary documentation on the connection string format: v4.4, v6.3 current.

Indiekit specifies which database to use when it starts up, too:

const database = this.client.db("indiekit");

So, with all that said, I think the current documentation is correct.

If you let me know which service you are hosting your Indiekit server on, and what version of MongoDB you have installed, I can work out if any platform-specific guidance is needed.

@paulrobertlloyd
Copy link
Collaborator

paulrobertlloyd commented Feb 18, 2024

With #695, Indiekit will now notify users more prominently about connection issues. It will also use any database name given in the connection string (else use the default, test).

This is a breaking change that will ship in the next beta release, and I’ve added a note to the documentation highlighting this change.

@paulrobertlloyd
Copy link
Collaborator

I wonder if this situation occurred due to the way connection strings are handled.

Without username and password in the connection string:

mongodb://<host>:<port>/<database>

With a username and password in the connection string

mongodb://<username>:<password>/<database>?authSource=<defaultauthdb>

If username and password are provided, but the authSource option isn’t, it assumes that the value for is the authentication database (which it invariably isn’t):

mongodb://<username>:<password>/<defaultauthdb>

God, this is confusing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Good documentation benefits everyone question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants