Skip to content
OMG.js is an Object-Relation Mapper for HTML5 Local Storage
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

omg.js: An object oriented interface, ORM, and caching layer for HTML5 Local Storage

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.


Create Collections

Create an empty collection


Create a collection with seed data by passing an object.

omg.create('People', {name: 'Zelda'});

or pass an array of objects.

omg.create('People', [{name: 'Link'}, {name: 'Ganon'}]);

Add Objects

Add singe object (or array of objects) to collection

omg.add('People', {name: 'Navi'});

Read / Get Objects

Get an entire collection as an array of objects


Get a single object from a collection (by ID)

omg.getOne('People', '_xrtfghn09');

Get an array of objects by property

omg.getBy('People', 'name', 'Link');

Get any property from an object

omg.getOne('People', '_xrtfghn09').name;

Delete objects

Delete any collection


Delete a single object from collection by ID

omg.deleteOne('People', '_xrtfghn09');

omg automatically generates a unique ID for every object added to storage.

Update / Save

Update single object in collection

var person = omg.getBy('People', 'name', 'Ganon'); = 'Ganondorf';'People', person);


Run callback functions when specific omg function is called

omg.on('create', function() {
	console.log('Something was created!');

To Do Soon

  • Write docs for caching objects
  • Rename caching functions to match other CRUD functions
  • only get/set on window load/unload or during user silence

Set up relationship'People', 'Weapons');

Get Weapons of People _ax4e390x

omg.get('People', '_ax4e390x', 'Weapons');

Limit return to 2

omg.get('People', 'Weapons').limit(1);

Last / First Weapon

omg.get('People', '_ax4e390x', 'Weapons').first();
omg.get('People', '_ax4e390x', 'Weapons').last();

To Do later

  • 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.)
You can’t perform that action at this time.