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

Ability to set database name #149

Closed
mifozski opened this issue May 10, 2023 · 11 comments
Closed

Ability to set database name #149

mifozski opened this issue May 10, 2023 · 11 comments
Labels
enhancement New feature or request

Comments

@mifozski
Copy link

Evolu should expose the ability to define a database filename that will be created on OPFS so the users can have multiple databases on the same origin (for example, for multi-account usage).
The database filename should be passed as a param to the createHooks method in the Config object.

@steida
Copy link
Contributor

steida commented May 10, 2023

@mifozski I agree. The problem is that LocalStorage used where OPFS is unavailable, does not support multiple databases.

This VFS supports only a single database per storage object. That is, there can be, at most, one localStorage database and one sessionStorage database.

https://sqlite.org/wasm/doc/trunk/persistence.md

The affected browser is Safari. A bug blocking OPFS is already fixed, but it will take time to be available for all.

If you have an idea how to solve it, feel free to help 🙂

@steida steida added the enhancement New feature or request label May 10, 2023
@mifozski
Copy link
Author

mifozski commented May 11, 2023

@steida My idea was to just focus on the support for the OPFS storage, and I think we can decide that it's not going to be supported with localStorage, and Safari has its own limitation that are unrelated to this change.
But overall, I was planning to help with raising a PR for the OPFS support.

@steida
Copy link
Contributor

steida commented Oct 23, 2023

OPFS for Safari is already implemented in Evolu, so I suppose we can wait a few months for Safari 17 to be adopted, and then drop LocalStorage entirely. Then we can add support for more databases.

@steida
Copy link
Contributor

steida commented Feb 26, 2024

Related #309

@danilaplee
Copy link
Collaborator

hey i actually implemented this

@negue
Copy link
Collaborator

negue commented Mar 1, 2024

hey i actually implemented this

Nice!, do you have a snippet of how you did that?

Looking at #309 I think we'll have an official implementation soon ™️ 🎉

@steida
Copy link
Contributor

steida commented Mar 2, 2024

So how should the Evolu "multitenancy" work? What are the use cases? 🤔

The first use case is dev on localhost, where each app would be isolated from others. That would be nice.
For that use case, the config can accept the optional name.

The second use case is the ability to have more Evolu instances run concurrently and even dynamically 🤔
That's perfectly possible, but I must rework Evolu internals first.

@danilaplee
Copy link
Collaborator

i will provide an MR next week

@steida steida closed this as completed in 6af55b7 Mar 4, 2024
@negue
Copy link
Collaborator

negue commented Mar 5, 2024

closed this as completed

ohh awesome!!

@steida
Copy link
Contributor

steida commented Mar 5, 2024

@negue It doesn't mean that more Evolu instances can be used concurrently. It will be possible, but not yet.

@negue
Copy link
Collaborator

negue commented Mar 5, 2024

I for one only needed a different database name so far - I wont have two apps / evolu instances in the same browser tab :)

The other multiple instances feature I'll probably use as well but not a missing feature for me (yet)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants