javascript - immutable chrome sqlite return objects -


i using sqlite db storage system webapp. been using objects returned queries directly in application. example:

function get_book_by_id(id,successcallback,errorcallback) {     function _successcallback(transaction, results)     {         if(results.rows.length==0) {successcallback(null);}         else         {             book=results.rows.item(0);             successcallback(book);         }     }     db.transaction(         function (transaction) {             transaction.executesql("select id,title,content,last_read books id=?;",[id], _successcallback, errorcallback);     }); } 

this returns me object given id, columns provided properties. nice. problem figured out properties of result set object immutable. example if want change property 'title' takes no effect, in opinion makes no sense. example:

get_book_by_id(1,handle,error); function handle(book) {  //this doesn't work, book.title still was.  book.title=book.title+"more text";  } 

i of course can convert db objects mutable objects, rather not that.

is expected behavior? can request mutable objects?

i using google chrome 9.0 on mac os x.

the websql spec doesn't require returned item sealed, it's implementation (the spec require item ordered dictionary properties in same order columns in query).

and no, there no way explicitly request mutable object, you'll want convert_to_mutable() approach suggested stan.

btw, assuming you're using 3rd party library, has function this, example jquery.extend() or _.extend().


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -