-
Notifications
You must be signed in to change notification settings - Fork 49
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
Feature: Create stores dynamically #29
Comments
You want it, write a PR. I have no need for this functionality and it does not exist. I personally think that an implementation that dynamically makes object stores is broken design. |
Hey guys, First off, you don't need to create/connect to your DB solely in your config phase, you can do it in any service (might take a couple tweaks in the library to do so, I can't remember). I've done some work around this. I've extended the library to support managing multiple indexedDB databases at once rather than having only one at a time. I modified the connection mechanism to allow you to switch between any N number of DBs you create within a single session on your browser. I haven't gotten around to doing the PR for that (plus some other optimizations) yet, but I'll try to do it soon. That should give you the functionality you're looking for @prabhuish @bramski I can see what you mean by "broken design", but there are instances where you'll need to establish more than 1 indexedDB. In my scenario. I can explain mine if you'd like :] |
Here's an example of how I am connecting to this local DB from within a service called Anyway, notice that I am referencing the
To get this to work, I had to extend the actual service with a couple of methods in the return object at the very bottom of the
|
I don't really want this kind of complexity. In my 16 years developing Web What is the useage case for this? You haven't actually given me a solid Right now my answer is that you should roll your own solution to this
|
@bramski I know what you mean. It's not too highly complex though. Think of a scenario where you can have a user simultaneously access two separate accounts in your app within the same session. Twitter is an example of this; you can switch between connected accounts. Rather than blasting the entire indexedDB when you switch the account, you can simply tell your library to point to the DB for account A, or to account B. In my scenario, my user can choose between any number of SharePoint sites that they have access to. Each SharePoint site contains a series of lists which stores all of the data used by the app (don't ask...). Point is, they can switch between 5 different sites within the same session if they wanted to, use the data, and then connect to a different site. All of that data needs to be stored locally in my situation, so rather than blasting all of the data away in 1 database whenever they switch connections, I maintain all 5 local databases and just update the current database name in the library to keep track of the db they are connected to. For argument's sake, there isn't really a limit to how many indexedDBs you can create with JavaScript - you could create 2, 3, 4, 5, 10 DBs locally if you wanted (for whatever reason). This angular library shouldn't prevent that by restricting you to only 1 library. Besides, the upgrade is actually very simple, it only took me about 15 minutes to enable the capability of closing the connection to one DB and opening a connection to another DB. Works like a charm. |
Are you going to write a PR for this or add an additional service that allows you to manage multiple DBs? I had thought you'd opened a PR to add the functionality you wanted, but I don't see one in the repo. |
Yeah, I've been slammed at work so I haven't had a chance to open a PR. Sorry about that. I made the modification directly to the javascript, not the coffeescript, so there's obstacle #2 for me to hurdle :]. I'll try to get something out this week so you can take a look. |
Simple example for dynamic creation: I have a logging component that I want to persist data between browser sessions. I'm building it as a reusable component, to be added to multiple applications via bower install. Those applications will call the logging component, but be unaware of the database requirements underneath. They may even have their own IndexedDB, or share a DB, but the structures are abstracted from the main app. So, there are many cases for creating object stores at a component level, not simply at an application level. |
Talk is cheap. Write a pull request!
|
Very true, talk is cheap, but it's also true that work is expensive. Put
|
I was not paid to make this plug in better nor open source it. Don't ask
|
Whoa, chill with the hostilities, man! It was stated that there was no
|
@CraigWarford, please be kind and appreciate what @bramski have done so for the group. You can not generalize it is not useful for any purpose because I am using it for my project which is working fine. I have modified the code slightly to support for my need and it is working fine as expected. I logged this as a needful enhancement because I thought it would be a good feature to have. In many libraries that I have seen so for is working with single store, however it still should be possible to enhance to work with multiple.. |
Ahh yes. Sunday @8am. Probably hungover pre coffee. Sorry for the antagonism! |
In my case, I have to add stores when needed. But looks like this implementation offers to create stores during config phase. Can you please guide me to create multiple stores dynamically.
The text was updated successfully, but these errors were encountered: