Tuesday, November 24th, 2009
Moving from the Couch to the LawnChair
We have mentioned attempts at doing Couch in the browser before, and now we have a new project.
Brian LeRoux of PhoneGap/Nitobi fame, has taken a lighter couch outside as he announces Lawnchair that aims at being applicable for mobile Web usage (but can of course work anywhere else):
Features
- micro tiny storage without the nasty SQL: pure and delicious JSON
- clean and simple oo design with one db table per store
- key/value store.. specifying a key is optional
- happily and handily will treat your store as an array of objects
- terse syntax for searching and therefore finding of objects
Give it a hack:
-
-
// create a store
-
var people = new Lawnchair('people');
-
-
// -- adding to the store
-
// Saving a document
-
var me = {name:'brian'};
-
people.save(me);
-
-
// Saving a document async
-
people.save({name:'frank'}, function(r) {
-
console.log(r);
-
});
-
-
// Specifying your own key
-
people.save({key:'whatever', name:'dracula'});
-
-
// -- Getting content out
-
-
// Get that document
-
people.get(me.key, function(r){
-
console.log(r);
-
});
-
-
// Returns all documents as an array to a callback
-
people.all(function(r){
-
console.log(r);
-
});
-
-
// List all with shortcut syntax
-
people.all('console.log(r)');
-
-
// -- Removal
-
-
// Remove a document directly
-
people.get(me.key, function(r){
-
people.remove(me);
-
});
-
-
// Remove a document by key
-
people.save({key:'die', name:'duder'});
-
people.remove('die');
-
-
// Destroy all documents
-
people.nuke();
-












looks interesting, however, i’m not sure how i feel about “people.nuke();” haha
Why do i want to use this over localStorage?
localStorage.setItem("name", "Brian");
var name = localStorage.getItem("name");
localStorage.setItem("data", {"foo":"bar","flip":"rep","arr":[1,3,4]});
var data = localStorage.getItem("data");
@Jaaap — many stores and searching. A slightly better api. The future ability to back the store by other technology (such as local,global,session storage) to make it more portable is planned.
Always loved anything to do with CouchDB — @Brianleroux, ever done any work with IBM’s Domino Framework?
@brianleroux – I’m with jaaap on this; show me the chocolate chips and I’ll choose your cookies, or I’m going to pick vanilla.
@mdmadph: no but I’m a big fan of document stores.
@sixtyseconds: About to release android 1.5,1.6 and 2.0 support so there’s your cookies buddy.
Early versions of Android only support the gears sqlite interface (different than the webkit sqlite api) and no localStorage. Consistant API and mobile web friendly is the goal.
also have a look at Syncopate, another Web Database/HTML5 wrapper:
http://github.com/thynctank/Syncopate
and the buy aion gold security aion power levelingofjustice. roll forming machinewe have buy wow goldalso come to this hallowed spot
shanghai escortto remindamerica cheap wow goldof the fierce urgency of now. this is no time to engagein the luxury of cooling off or
Lawnchair has create 3 databases in Safari with the same name. How do I delete ( remove, drop, etc ) the databases create with this?