Coder Social home page Coder Social logo

lawnchair's Introduction

	.____                                 .__            .__         
	|    |   _____  __  _  ______   ____  |  |__ _____   |__|_______ 
	|    |   \__  \ \ \/ \/ /    \_/ ___\ |  |  \\__  \  |  |\_  __ \
	|    |___ / __ \_\     /   |  \  \___ |   Y  \/ __ \_|  | |  | \/
	|_______ (____  / \/\_/|___|  /\___  >|___|  (____  /|__| |__|   
	        \/    \/            \/client\/ json\/store\/ 

To learn more visit http://brian.io/lawnchair or check out the ./doc folder in this repo.

lawnchair's People

Contributors

ahaedike avatar andreabalducci avatar brianleroux avatar cameronhunter avatar cscott avatar cwilso avatar demaniak avatar evanshortiss avatar fitzgen avatar funkatron avatar jchris avatar josephpecoraro avatar knisterpeter avatar markmyoung avatar mosch avatar mwbrooks avatar nubs avatar omailson avatar paolobueno avatar paulirish avatar peterp avatar pulsation avatar resonance1584 avatar sjoerdmulder avatar stigtsp avatar subhash85 avatar thynctank avatar tricki avatar tristanstraub avatar wtrocki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lawnchair's Issues

Cookie adaptor in Black Berry 4.6 trips on =

If you try to retrieve an object back from the cookie adapter in 4.6 and if it also has an '=' in it, it'll alert you with an unterminated string literal. I think the '=' needs to be encoded when saving.

save() removes object's key

Lawnchair (at least DOM storage mode) removes the object's key upon save().

Example code:

var l = new Lawnchair({table:"testingdom", adaptor: 'dom'});
var item = {key:'123', value: "testdom"};
l.save(item, function() { console.log(JSON.stringify(item)); });

Output:

{"value":"testdom"}

Expected output:

{"key":"123", "value":"testdom"}

I know you can get around it by having the callback function accept
a single "item" argument, but that doesn't help in the case of
multiple variables all referencing the same item object.

WebSite tutorial not up to date ?

It seems the tutorial available here http://blog.westcoastlogic.com/lawnchair/ isn't up to date.

Constructor seems to expect an object with adaptor member set to the adaptor required and the example reads:

var people = new Lawnchair('people');

Expecting some kind of identifier...

A complete working example (including required includes) would help. Any plan to update the website ? I could help if you need it...

dropped transactions on iPad, iPad simulator (works in Safari on OSX)

I'm using Lawnchair as part of SroutCore application that makes several inserts into the store. Each subsequent inset doesn't wait until the first insert completes.

The behavior I'm observing is that the first transaction never completes in case a second transaction was started.

Specifically:

insert: function(obj, callback) {
    var that = this;

    console.log("Lawnchair.save.insert obj=%@".fmt(obj));

    that.db.transaction(function(t) {
        console.log("Lawnchair.save.insert.transaction t=%@ obj.key=%@".fmt(t, obj.key));

        var id = (obj.key == undefined) ? that.uuid() : obj.key;
        delete(obj.key);
        console.log("SQL: INSERT INTO %@ (id, value,timestamp) VALUES (%@,%@,%@)".fmt(that.table, id, that.serialize(obj), that.now()));
        t.executeSql(
            "INSERT INTO " + that.table + " (id, value,timestamp) VALUES (?,?,?)",
            [id, that.serialize(obj), that.now()],
            function() {
                console.log("executeSQL INSERT success on %@ calling callback %@".fmt(that.table, callback));
                if (callback != undefined) {
                    obj.key = id;
                    that.terseToVerboseCallback(callback)(obj);
                }
            },
            that.onError);
        },
        that.onError,
        function() { console.log('INSERT: tx succeeded on table %@'.fmt(that.table));}
    );

The function

function() { console.log('INSERT: tx succeeded on table %@'.fmt(that.table));}

will not be called.

It doesn't seem to be an issue with Lawnchair logic per-se, more like a bug of Safari on iOS. But even so, it cripples Lawnchair in a big way.

As a fix, one option is to add a new adapter iOSWebkitSQLiteAdaptor that will queue the insert and update requests and execute them in a sequential/chained way.

IndexedDB adapter fails in FF4+

While running the examples on http://westcoastlogic.com/lawnchair/saving/
I got the following error

[Break On This Error] var request = obj.key ? store.put(obj, obj.key) : store.put(obj);
error in indexed-db adapter! error undefined
indexed-db.js (line 87)

Going through the indexed-db.js code i found

and similar "teststore" statements throughout the code.
Shouldn't the store name be passed as a parameter?

Surprisingly the adapter works in Chrome (14.x).

Problem on first query to a table

Hi,
I'm developing an app that has to run on PhoneGap using both Android 2.x and iPhone 4.x I'm having a problem with iPhone in the first query of a table. I've been looking at the code and I see that when you create an object, it does a select to see if the table exists and if it does not it creates it. However, if you create a new Lawnchair object and just after that you try to query an object in that table for the first time, the query is actually done before the table check transaction fails, hence the table is created after the query is done, raising an error of "no such table".
I guess I'll be able to work around this by using a timer, and I guess this will be hard to solve given the asynchronous nature of the WebKit SQL, but it's worth looking it.

Cheers!

Make indexed-db adapter browser-independent

Hi brian,

Your indexed-db adapter is using the prefixed transaction ("webkitIDBTransaction") where it should evaluate the right prefixed version in a function similar to getIDB().

Is the documentation included in the MIT license

I am writing a book on HTML5 Apps, and as apart of that I have started work on a small, simple MVC, I want to use lawnChair as the data/model component of the MVC. In the book I need to have a small section about how to use lawnChair, I would like to use the examples provided on this page

http://brianleroux.github.com/lawnchair/

and update them as I am not entirely certain they are valid anymore I don't hink you can can instantiate a table like this anymore

var people = new Lawnchair('people');

I think you have to do it like this right?

var people = new Lawnchair({table:"people",adaptor:"dom"});

either way, I would like to save my self some time and build on the great work you guys have already done, thanks.

"Cannot call method 'transaction' of null" error in Chrome v3.0.195.38

var people = new Lawnchair('people');
TypeError: Cannot call method 'transaction' of null

I tried not include the WebkitAdaptor, hope it will automatically use GearAdaptor, then I got this:

var people = new Lawnchair('people');
ReferenceError: WebkitSQLiteAdaptor is not defined

Filenames don't match object names

The adaptor object names and corresponding file names use different, inconsistent capitalization. This confuses both the programmer and auto-completion in text editors.

One offending example:

WebKitSqliteAdaptor.js => WebkitSQLiteAdaptor
Capital WKSA => Capital WSQLA

Suggested solution: Use the object name as the filename.

WebkitSQLiteAdaptor.js

TypeError: Converting circular structure to JSON

Running this on webOS 2.1 with the Webkit SQLite adaptor, when I try saving a document with a few array values, I get a circular structure warning. I've investigated everything very closely and don't see any place where a circular structure could take place. Here's an example of what I'm trying to save.

var doc = {
key: 123,
items1: [...array of JSON objects...],
items2: [...array of JSON objects...]
};

To make matters worse, it worked just fine for a few times and then pooped out for no reason.

Any idea what the deal is?

Object with same key duplicated, not updated.

new Lawnchair(function() {

    this.save({key: 'pew', attr1: 'value1'});
    this.save({key: 'pew', attr1: 'value1'});
    this.save({key: 'pew', attr1: 'value1'});

    this.all(function(o) {
        console.log(o); // Object , Object, Object
    });
});

Oddly enough, if I allow Lawnchair to save and determine its own key the duplication doesn't occur:

new Lawnchair(function() {

this.save({dummy: 'object');
this.save({key: 'pew', attr1: 'value1'});
this.save({key: 'pew', attr1: 'value1'});

this.all(function(o) {
    console.log(o); // Object , Object
});

});

The memory adapter should store JSON-encoded strings

Otherwise, you can get aliasing effects that you don't get with other adapters.

I just switched to the dom adapter for unit testing an application to avoid this problem.
That forced me to implement localStorage, as it's not provided by envjs 1.2.

(I'm running unit tests under python-spidermonkey and envjs 1.2.)

webkit adapter allows write-only non-string keys

The webkit-sqlite adapter allows non-string keys in get requests, but
can't look up the saved objects.

db = new Lawnchair({name: 'xxx'}, function() {})
Lawnchair
db.save({key:'3', a: 1})
Lawnchair
db.get('3', function (o) {console.log(o.key)})
Lawnchair
3
db.save({key:2, a: 1})
Lawnchair
db.get(2, function (o) {console.log(o)})
Lawnchair
null

This is in 0.6.3. I didn't have this problem in 0.5.0.

The dom and memory adapters allow integer keys.

I couldn't find anything in the docs saying that keys had to be
strings.

Duplicate Items or adapter script question ?

Here are my code. http://pastebin.com/w5WN9iFb

If I did not include adapters/dom.js, it generates an error : uncaught exception: No valid adapter.

If I did include the adapter script, it generates another error :

this.lambda(callback).call is not a function
[Break On This Error] this.lambda(callback).call(this, obj)

or sometimes, duplicate the results.

What did I do wrong ? Please, help.

better diagnostics for errors relating to adaptor choice

If I've specified an adaptor that I want to use, but the code is unable to load it, I'd like to see a message to that effect - including the key and adaptor class name - logged to the console.

In addition, if the "more flexible adaptor choice" issue is implemented, I'd like to just see the message above logged to the console as a warning, but continue to try loading another one. If NONE of them can be loaded, log again to the console ("couldn't load any") and throw an Error.

multiple tables crash?

For each table created a new instance of database is also created. Performance becomes a dog, can't even run on iPhone. This is using the WebKitSQLite adapter.

To repo:

var _tableone = new Lawnchair('one');
var _tabletwo = new Lawnchair('two');
var _tablethree = new Lawnchair('three');

Using web inspector note three DB instances.

saving randomly fails when having more than one store

Hi,
when I create two stores when the device and document is ready, the first store never makes any problems but the second store is prone to errors in the beginning as trying to save something fails randomly.

In fact I only know when something fails at table creation:

var logdb = new Lawnchair({table:'log'+my_key, adaptor:'webkit', onError:function (o,e){console.log("SQL error [" + e.code + "]: " + e.message)}});

I also displayed what's being printed inside the .each "loop" (ignore the count):

2011-03-24 02:05:45.065 lifelog[5272:707] [INFO] count: 1
2011-03-24 02:05:50.741 lifelog[5272:707] [INFO] count: 1
2011-03-24 02:05:50.749 lifelog[5272:707] [INFO] Object:
name = bar
key = ts2_5_44
2011-03-24 02:06:05.367 lifelog[5272:707] [INFO] count: 1
2011-03-24 02:06:05.376 lifelog[5272:707] [INFO] Object:
name = bar
key = ts2_5_44
2011-03-24 02:06:05.388 lifelog[5272:707] [INFO] Object:
name = bar
key = ts2_5_50
2011-03-24 02:11:25.735 lifelog[5272:707] [INFO] count: 1
2011-03-24 02:11:25.757 lifelog[5272:707] [INFO] Object:
name = bar
key = ts2_5_44
2011-03-24 02:11:25.765 lifelog[5272:707] [INFO] Object:
name = bar
key = ts2_5_50
2011-03-24 02:11:25.775 lifelog[5272:707] [INFO] Object:
name = bar
key = ts2_6_5

In fact I expected more entries :). What I also noticed was when I leave the app open for some time it saves the requested entries very reliably but I think it's related to the "store" itself because when I restart the app it works as expected.

I don't really know what's the problem here. For me it's very unreliable when I create more than one store.

When I save an entry I'd like to know if that failed or not. Is there some way to accomplish that?

Thanks.

WebkitSQLiteAdaptor needs to provide a mechanism to handle transaction errors

When executing SQL in an SQL Storage, errors can be generated for either the SQL statement or the database transaction. The Webkit adapter provides a way to handle the former (by passing an onError option), but not the latter.

Specifically, we need to be able to provide an errorCallback when calling the database's transaction and readTransaction methods (see http://www.w3.org/TR/webdatabase/#asynchronous-database-api). This should be a different handler than the onError callback.

Applications will likely need to handle these errors. For example, my application wants to know when the maximum database size has been exceeded, which is raised as a transaction error.

Also, I'm pretty new to github. Would it be helpful for me to create a fork with my workaround and then initiate a pull request?

Does Lawnchair work in Palm (WebOS)?

Hi,

After including the Lawnchair.js file and in the first line of simple put and get example:

var people = new Lawnchair('people');

I'm getting the following error, shown in the palm log viewer:

[20100430-15:41:34.118953] error: Uncaught ReferenceError: WebkitSQLiteAdaptor is not defined, Lawnchair.js:24

Regards!
David

JSON.parse(window.top.name) can cause all JS to stop executing

We just had a major issue on the site due to this bug.
in the 'window-name' adapter, there is a call:

data = window.top.name ? JSON.parse(window.top.name) : {}

when the window.top.name is not valid json, this will throw an exception which causes all JS loaded after this to fail.

fix is:

var data;
try {
data = window.top.name ? JSON.parse(window.top.name) : {}
} catch(e){
data = {};
}

Lawnchair constructor callback

Hi, @brianleroux. Can you explain the expected usage of the Lawnchair function/constructor and the callback parameter? (See #38.)

The problem is some adapters need to do something async in their init function before the store is ready to be used (e.g., IndexedDB). Getting the Lawnchair instance in a synchronous manner via the return value of the Lawnchair function or the new operator promotes using the object immediately after the call to the Lawnchair function. This is fine in most cases (i.e., DOM storage), but may fail when using another adapter. Consider this example:

var store = Lawnchair(function(store) { console.log ("store ready", store) });

// The following `store.save()` call can fail
// e.g., the IndexedDB adapter's object store `teststore` is not yet created
store.save({});

Thus we should only use the Lawnchair object from within the callback. I figure that's why you made the callback required, but I think also returning the object in the synchronous manner is confusing. The API should be sync or async, not both.

Make fails on linux

First, src/Lawnchair.js is the filename, but referred to as src/lawnchair.js from the makefile. The makefile itself is commonly cased as Makefile, but that's not important.

Second, the script assumes the OS X 'open' command, which does something entirely different on linux. The equivalent linux command is xdg-open.

IndexedDB adaptor

Firefox has indicated they will not implement web sql database, but will instead add IndexedDB.
Chrome will have both.
Safari and Opera support web sql database and havent said anything about Indexeddb.
IE is eternally vague.

http://hacks.mozilla.org/2010/06/comparing-indexeddb-and-webdatabase/
http://hacks.mozilla.org/2010/06/beyond-html5-database-apis-and-the-road-to-indexeddb/

The lawnchair API appears to play very nicely with IndexedDB.
Does it make sense to add an adaptor?

No way to tell if an item exists

As far as I can tell (I may be missing something), there is no way to check if an object with a given key exists.

get() and find() never call the callback in the case where no object exists. Since callbacks are asynchronous, there is no logical point where application code could check to see if it has received a result or not from any of these calls.

I think that either get() should call you back (with null), or there should be an exists() method added for this purpose.

I can use all() for the moment as a workaround, but obviously that is inefficient for large stores.

My use case is that I want to create a default object if none exists with the given key, but I don't want to simply save() one since that would overwrite an existing object.

What is the purpose of passing a callback when creating a new Lawnchair object?

There is actually nothing async about this code it seems. The callback is called immediately.

var Lawnchair = function(opts, cb) {
    if (typeof cb == 'undefined') throw "Please provide a callback as second parameter to Lawnchair constructor; this shit's async, yo.";
    if (!JSON || !JSON.stringify) throw "Native JSON functions unavailable - please include http://www.json.org/json2.js or run on a decent browser :P";
    this.init(opts);
    cb.call(this);
}

This means that the docs at http://westcoastlogic.com/lawnchair/ are incorrect, where an object is created without any cb.

var people = new Lawnchair('people');

Callback after Creating Lawnchair Object

Hi,

Thanks for the powerful db adapter first
I tried to use this on both web-based and phonegap based application.
It works great in my web-based(chrome, safari...) application with webkit sqlite :)

for my phonegap project, I tried to build an android application with the same source code, phonegap and lawnchair.
There are 2 cases:

  1. If the app is 1st installed and launched, the script will be dead when there is any function call, let's use store as the object. e.g. store.get(....) store.all(......) store.save(...)
  2. Close the apps, and restart the apps, everything fine.

Did I miss something before calling .get .all? or did I miss something after new Lawnchair?
Thanks.

more flexible adaptor loading

It would be nice to be more flexible in the adaptor loading code; basically, if the adaptor requested isn't available, traverse the list of potential adaptors, looking for one that's loaded, and try to use it.

Ideally, the adaptors would be loaded into a separate object, rather than "var"d up, so you can more easily check to see if they exist. Suggest a global "LawnchairAdaptors" global, which is just used as a hash table. Should also trap the adaptor constructor invocations - on error, skip and try the next one.

small issue with save

Hi Brian,

Picked up something while playing with Lawnchair on Chrome.

var me = {name:'yoda'};
people.save(me);
people.get(me.key, function (r){
console.log(r);
});

---output---
null

but if you another line in there
people.save({name:'joe'});

it'll work fine.

JSON.parse: unexpected character (lawnchair 0.6.1)

JSON.parse: unexpected character
valid(a=undefined, c=undefined)lawnch....min.js (line 10)
lawnchair-0.6.1.min.js()lawnch....min.js (line 10)
[Break On This Error] Lawnchair.adapter("window-name",functi...b;window.top.name=JSON.stringify(e); 

Somehow, this error only appears per browser session and when there are form submits involved...
For now I just commented the window-name adapter.

dom adapter adds lawnchair name to keys

When objects with keys are saved and then loaded, the loaded objects
have the lawnchair name as a prefix:

db = new Lawnchair({name: 'xxx'}, function() {})
Lawnchair
db.save({key:'3', a: 1})
Lawnchair
db.get('3', function (o) {console.log(o.key)})
xxx.3
Lawnchair

This isn't true for the webkit-sqlite or the memory adapter.

Trying to move to latest version

Hi, I'm trying to move to the latest version, which it seems has a new API, I've got past a few of the errors, but I'm getting:

Result of expression 'self.storage' [undefined] is not an object.

at line 29 in dom.js.

I've included dom.js, and lawnchair.js, and changed how I instantiate a Lawnchair object , but still no luck. I'm on Adobe AIR, which used to work fine on the older versions of Lawnchair I've used. I expect I'm just doing something wrong, but I can't find many docs which explain what's changed from the older versions.

I note there is no longer a dedicated Adobe AIR adapter, am I better off going back to an older version of Lawnchair?

Thanks

Garry

Adds globalStorage as one of the adapters

globalStorage is an attempt on the persistent storage field before HTML5 era. It's pretty much like the current localStorage standard thus should be pretty straightforward to support.

Many thanks,
J

query plugin ie

ie does not support the filter function used by the query plugin, the function needs to be patched in.

// ie fallback from MDN: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/filter
if (!Array.prototype.filter)
{
  Array.prototype.filter = function(fun /*, thisp */)
  {
    "use strict";

    if (this === void 0 || this === null)
      throw new TypeError();

    var t = Object(this);
    var len = t.length >>> 0;
    if (typeof fun !== "function")
      throw new TypeError();

    var res = [];
    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
      if (i in t)
      {
        var val = t[i]; // in case fun mutates this
        if (fun.call(thisp, val, i, t))
          res.push(val);
      }
    }

    return res;
  };
}

Exists function

This snippet triggers the following error:

Uncaught TypeError: Object # has no method 'exists'

Lawnchair(function() {

    this.save({key:'1',title:'jewels'});

    this.exists('1', function(exists){
        console.log(exists + ' exists')
    });

});

each() includes all tables in dom storage mode

I have two lawnchair stores in DOM storage mode, named "tags" and "entries".

When I run tags.each(), I get called back for every element in both stores (i.e I get entries back as well).

in the default storage mode (webkit sqlite?), I get only the objects from the "tags" store, as expected.

I can knock up some code to reproduce if you need, but it's hopefully easy to track down.

[lawnchair version 0.3.0]

Cookie 'PHPSESSID' problem

Often if site has server side PHP and use session vars there is also cookie with name 'PHPSESSID' for this domain. In this case method .all() is not working since it trying to deserialize their contents.
Please add this line:
if (k == 'PHPSESSID') continue;
in CookieAdaptor.js [64] to fix this.

Callback for all() on a freshly init Lawnchair Object never get called

System:
WebOS 1.4.5 (both emulator and device)

Steps to reproduce:
In a new scene (e.g. test-assistant.js)
function TestAssistant(args) {
this.test = new Lawnchair({name: "test", table: "testTable", adaptor: "webkit"});
}
TestAssistant.prototype = {
setup: function() {

     this.testDb.all(function(r) {
        Mojo.Log.info("Got items from DB: ", r.length);
        this.setupItemsHandler(r);
    }.bind(this));
}
 }

The "this.setupItemsHandler()" is not called, so I don't know if the DB is empty, to fetch some data or just stick with the DB entries.
If I swipe back a scene and call the scene again, the handler is called and the log says e.g. "Got items from DB: 0"
If the DB has already some objects, than all runs fine from the beginning, it seems this behavior is only on a new created Lawnchair.

This issue is always reproducable.

"unterminated string literal" error when deserializing

If I try to retrieve the following value from a Lawnchair Dom storage table

setup mysql backups to S3 for ACME production DB server (http://www.timlinden.com/blog/server/backup-mysql-amazon-s3/
http://www.backup-manager.org/about/
or
http://code.google.com/p/s3fs/wiki/FuseOverAmazon)

I get an "unterminated string literal" error in LawnChairAdaptorHelpers.js on line 96 when it tries to deserialize the json.

I was able to duplicate it in FireFox 3.6.10 and Safari 5.0.2. Trying to figure out exactly why its happening so I can detect it and ideally sanitize it before trying to save.

P.S. Lawnchair rocks!

Out-of-space errors not handled?

I've been doing a port of lscache to use Lawnchair instead of always going to localStorage. However, when I hit the part of the code where she tries to put something into the cache and cannot because the storage mechanism is full, I hit a wall.

In glancing through the various Lawnchair adapters, it doesn't appear that many of them expect an error to occur when saving. And if they do, then it doesn't appear to me like there's a anything to catch the various storage mechanism specific errors and rethrow a uniform set of Lawnchair errors. Are there plans for this? Or is it already there and I'm just not seeing it.

BTW, the project is here (https://github.com/JohnMunsch/lccache) and other than the error handling, it works quite well so far.

DOM storage doesn't work for a local file:/// webpage in Firefox

I don't know whether this needs to be any of Lawnchair's business, but if a local page (say file:///some_location_on_your_computer/index.html) uses DOM storage (i.e. localStorage) to save stuff, it fails silently. The callback function is called and all seems well. But then when you reload the page, nothing that got committed to localStorage is actually there any more.

See http://stackoverflow.com/questions/1492942/is-localstorage-in-firefox-only-working-when-the-page-is-online and https://bugzilla.mozilla.org/show_bug.cgi?id=507361

Perhaps Lawnchair should be aware of this, and fail or fall back to another method (such as cookies). Anyway, just a suggestion.

The version of Firefox I've been testing is Firefox 3.6.13 running on the 64-bit version of Ubuntu 10.10.

had to add DOMStorageAdaptor to spec/adaptors/webkit.html

The "dom" storage adapter seems to be used in the spec tests, and the existing webkit.html adapter does not include it. I added the line:

<script src="../../src/adaptors/DOMStorageAdaptor.js" type="text/javascript" charset="utf-8"></script>

after the WebKitSQLiteAdapter line in spec/adaptors/webkit.html; which allow the tests to run to completion. Without that line, you'll get a null pointer dereference when the tests reach for the 'dom' adapter.

When saving, passed object gets the 'key' value removed

I noticed that key is removed when saving if a callback function isn't supplied.

With this code, after save the variable data no longer has the key value.
var data = {key: "test", color: '#000000'};
db.save(data); // Notice that the callback is missing.
// data == {color: '#000000'}

With this code, after save the variable data has the key value.
var data = {key: "test", color: '#000000'};
db.save(data, function(obj) {}); // Notice that there is a callback this time.
// data == {key: "test", color: '#000000'};

I'm using:
brianleroux-lawnchair-0.6.3-0-g4ef3b28 with the dom adapter in chrome 14.0.835.126 beta-m

0.4.3 .save overwrites exisiting data

LC Version: 0.4.3
using with: JQ 1.4.2 (min)

Support script load:
<script type="text/javascript" src="jquery-1.4.2.min.js" charset="utf-8"></script>
<script type="text/javascript" src="jquery.peity.min.js" charset="utf-8"></script>
<script type="text/javascript" src="LawnchairAdaptorHelpers.js" charset="utf-8"></script>
<script type="text/javascript" src="WebKitSqliteAdaptor.js" charset="utf-8"></script>
<script type="text/javascript" src="Lawnchair.js" charset="utf-8"></script>

Instantiation: (in dashcode (i know, don't judge me), main.js )
var daba=new Lawnchair({name:'HuCa',table:'datatable',display:'HuCaData',adaptor:'webkit'});

failing call:
function addWeightButtonClick(event) {
daba.save({category:'weight',amount:$('#inWeightGraph').val()},
function() {graphWeightElements()})
$("#inWeightGraph").val("");
}

Result: This setup properly adds entries to the database/datatable, but overwrites each entry with new data (the generated ID is new, timestamp new, but will consistently overwrite the entry in the table.).

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.