Skip to content

samuraisam/angular-db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

angular-db

Simple IndexedDB access for AngularJS. Works great with IndexedDBShim!

This is basically an incomplete wrapper around db.js. Which is listed as a dependency in bower and must be included in the page.

Example Usage:

1. Install and include the library:

bower install angular-db
<script src="bower_components/db.js/src/db.js"></script>
<script src="bower_components/angular-db/db.js"></script>

2. Set up the DB:

angular.module('mymodule', ['db'])

.config(function($dbProvider) {
  $dbProvider.connection('myapp', 2, {
    config: { key: { keyPath: 'key' } },
    stuff:  { key: { keyPath: 'Obj.ID' } },
  });
})

3. Use the DB:

angular.module('mymodule.submodule', ['db'])

.controller('MyController', function($db) {
  // fetch the object store
  var myObjectStore = $db.objectStore('config').then( ... );
  
  // put something... all methods return a promise
  myObjectStore.save({key: 'stuff', otherkey: 'bla bla bla'}).then( ... );
  
  // fetch one object
  myObjectStore.find('stuff');
  
  // fetch all objects
  myObjectStore.getAll().then( ... );
  
  // etc... just look at the file until I write more docs. It's super simple.
})

About

Simple IndexedDB access for AngularJS

Resources

License

Stars

Watchers

Forks

Packages

No packages published