Local storage is dope, but current browser implementations only provide a UI blocking, string based interface for key-value pairs.
omg.js is an object oriented, CRUD interface for HTML5 Local Storage. It enables asynchronous read and writes with a built in caching layer for less code and better performing frontend applications.
omg.create('People');
omg.create('People', {name: 'Zelda'});
omg.create('People', [{name: 'Link'}, {name: 'Ganon'}]);
omg.add('People', {name: 'Navi'});
omg.get('People');
omg.getOne('People', '_xrtfghn09');
omg.getBy('People', 'name', 'Link');
omg.getOne('People', '_xrtfghn09').name;
omg.delete('People');
omg.deleteOne('People', '_xrtfghn09');
omg automatically generates a unique ID for every object added to storage.
var person = omg.getBy('People', 'name', 'Ganon');
person.name = 'Ganondorf';
omg.save('People', person);
omg.on('create', function() {
console.log('Something was created!');
};
- Write docs for caching objects
- Rename caching functions to match other CRUD functions
- only get/set on window load/unload or during user silence
omg.link('People', 'Weapons');
omg.get('People', '_ax4e390x', 'Weapons');
omg.get('People', 'Weapons').limit(1);
omg.get('People', '_ax4e390x', 'Weapons').first();
omg.get('People', '_ax4e390x', 'Weapons').last();
- Rename collections
omg.update('People', 'Characters');
- Make delete / update functions more efficient (Calling setItem() with a named key that already exists will silently overwrite the previous value.)