Ember CLI IndexedDB Wrapper
This addon provides a thin wrapper around IndexedDB to easily use in your projects.
Ember Data is not currently supported.
This library is still in very early stages so please treat it with suspicion until stabilised 😄
Installation
ember install:addon ember-cli-indexeddb-wrapper
ember g indexeddb-service <service-name>
This will then generate a file which you can use to configure the service
// Filename app/services/my-store.js; ;
optional (but recommended!) ember g initializer <service-name>
Which will generate an initializer. The name should match that of your service.
// Filename app/initializers/my-store.js { application; application;} name: 'myStore' initialize: initialize;
This allows you to use the service without having to inject the service in every area manually.
// Filename app/routes/application.js ; Route;
Alternatively you can skip the initializer and simply inject the service anywhere you want to use it.
// Filename app/routes/application.js ; Route;
Usage
After you've get things set up it should be fairly straightforward to use. All public methods return promises, so you know what to do with them.
Saving a record or records. The save
method takes two parameters, storeName
and thing(s)
to persist. thing(s)
can be a single object or an Array of objects.
// Filename app/controller/thing.js ; Route;
You can retreive records by index wtih a search term. call .getByIndex(storeName, indexName, searchTerm)
, This will return an array of objects where the searchTerm matches the key.
// Filename app/routes/application.js ; Route;
Running Tests
ember test
ember test --server
Contributions
Contributions for bug fixes are welcome with tests and documentation. Please reach out to me if you're thinking about adding a feature before sending a pull request. This reduces the likelihood of doing work that won't be merged. If you're forking for your own project then of course knock yourself out and go crazy!
If you want to make a suggestion, please open an issue on Github.
Whatever happens, remember, I put this out her for free, so if you don't like, don't agree or it doesn't work the way you want - please still be polite and constructive.