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

Multitenant Application in Doobie #1956

Open
guillaumebadin opened this issue Dec 4, 2023 · 2 comments
Open

Multitenant Application in Doobie #1956

guillaumebadin opened this issue Dec 4, 2023 · 2 comments

Comments

@guillaumebadin
Copy link

Hello,
we have a multi tenant application and we choose doobie for our sql.

Do we have a method in doobie to have a multi tenant application to force a filter for each transaction ?

For example hook transactor ?
Fragment hooks ?

@wedens
Copy link
Contributor

wedens commented Dec 4, 2023

You can modify Strategy.before to execute some ConnectionIO[Unit] in the beginning of each transaction that is executed with the modified Transactor.

val additionalBefore: ConnectionIO[Unit] = sql"SET search_path = ...".run.void 
// append an additional action to an existing one
val transactor0 = Transactor.before.modify(transactor, _ *>  additionalBefore)

@guillaumebadin
Copy link
Author

Thank you I'll try it.

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

No branches or pull requests

2 participants