Skip to content

basaundi/chongo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chongo Flattr this git repo Build Status

A mongo-like interface to browser Web Storage (localStorage and sessionStorage).

HEY CHONGO!

Basic usage

// Connection using sessionStorage, i.e. data is cleaned
//  when the browser is closed.
var con = new Chongo.Connection(sessionStorage);
var db = con.db('todos');   // "todo" database. Created if necesary.
var todo = db.col('todos'); // "todo" collection. Created if necesary.

// The next lines work as you'd expect.
todo.insert({title: "Buy apples.", completed: false});
var oid = todo.insert({title: "Take the trash out.", completed: false});
todo.update({_id: oid}, {completed: true});
var cur = todo.find();
while(cur.hasNext()){
	console.log(cur.next().title)
}

For more on the usage look in the demo and test folders.

Internal behaviour

Each document is stored separately as JSON under a key with the name $.<db name>.<collection name>.$<ObjectId>. An index of the documents in a collection in $natural order is stored under the key $.<db name>.<collection name>.

Current and planned features

  • CRUD
  • Indexing.
  • TodoMVC demo.
  • Minimized build.
  • Automatic synchronization with REST server.
  • Events.
  • Pluggable features for smaller library size.

License

The code is distributed under MIT license.

About

Mongo-like interface to localStorage.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published