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:

JAVASCRIPT:
  1.  
  2. // create a store
  3. var people = new Lawnchair('people');
  4.  
  5. // -- adding to the store
  6. // Saving a document
  7. var me = {name:'brian'};
  8. people.save(me);
  9.  
  10. // Saving a document async
  11. people.save({name:'frank'}, function(r) {
  12.     console.log(r);
  13. });
  14.  
  15. // Specifying your own key
  16. people.save({key:'whatever', name:'dracula'});
  17.  
  18. // -- Getting content out
  19.  
  20. // Get that document
  21. people.get(me.key, function(r){
  22.     console.log(r);
  23. });
  24.  
  25. // Returns all documents as an array to a callback
  26. people.all(function(r){
  27.     console.log(r);
  28. });
  29.  
  30. // List all with shortcut syntax
  31. people.all('console.log(r)');
  32.  
  33. // -- Removal
  34.  
  35. // Remove a document directly
  36. people.get(me.key, function(r){
  37.     people.remove(me);
  38. });
  39.  
  40. // Remove a document by key
  41. people.save({key:'die', name:'duder'});
  42. people.remove('die');
  43.  
  44. // Destroy all documents
  45. people.nuke();
  46.  

Related News :