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

docs(connections): add section on multi tenant #13449

Merged
merged 2 commits into from May 30, 2023
Merged

Conversation

vkarpov15
Copy link
Collaborator

Fix #11187

Summary

We get lots of questions about multi tenant, so would be nice to have a section of the docs to point people to.

Examples

Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, though one question and one suggestion

const express = require('express');
const mongoose = require('mongoose');

mongoose.connect('mongodb://127.0.0.1:27017/main');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this still required here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, to highlight that you do still need to connect before using useDb().

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from what i can tell, this code example does not use useDb, and rather createConnection and never the default connection itself

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair point, this mongoose.connect() call could be confusing. I put it here because in a multi-tenant scenario you may use the default connection to look up tenants. But not necessarily, so we can remove that.

lib/connection.js Outdated Show resolved Hide resolved
Co-authored-by: hasezoey <hasezoey@gmail.com>
@vkarpov15 vkarpov15 merged commit e069b6e into master May 30, 2023
32 checks passed
@vkarpov15 vkarpov15 deleted the vkarpov15/gh-11187 branch May 30, 2023 13:47
vkarpov15 added a commit that referenced this pull request Jun 2, 2023
docs(connections): remove unnecessary mongoose.connect() call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improved useDb() docs
2 participants