Dexie.js is a simple and concise library to work with the “Indexed Database API” or IndexedDB.
IndexedDB it is a way of storing data persistently in the browser. Given that allows the creation of web applications with enhanced query capabilities, These can be run both online and offline. IndexedDB is useful for applications that store a lot of data and applications that do not need a permanent connection to the Internet to work.
It can also be very useful to save data to local in a hybrid app for example.
Example of use:
/* |--------------------------------------------- | Make a database connection |--------------------------------------------- */ var db = new Dexie('MyDatabase'); // Define a schema db.version(1) .stores({ friends: 'name, age' }); // Open the database db.open() .catch(function(error){ alert('Uh oh : ' + error); }); /* |--------------------------------------------- | Then run some queries |--------------------------------------------- */ // Find some old friends db.friends .where('age') .above(75) .each(function(friend){ console.log(friend.name); }); // or make a new one db.friends .add({ name: 'Camilla', age: 25 });
Web: dexie.org
Documentation: GitHub