immutable chrome sqlite return objects

后端 未结 2 442
青春惊慌失措
青春惊慌失措 2021-02-08 10:36

I am using a sqlite DB as a storage system for a webapp. I been using the objects that are returned from queries directly in application. For example:

function g         


        
2条回答
  •  爱一瞬间的悲伤
    2021-02-08 11:07

    Building on Stepan's answer, but for people like me that want a quick fix from SO.
    You can create another basic object and copy the sqlite row properties onto it.
    Something like this:

    var immutable_book = results.rows.item(0);
    var book = {};
    for (var prop in immutable_book) {
        if (immutable_book.hasOwnProperty(prop)) {
            book[prop] = immutable_book[prop];
        }
    }
    

    That goes in the _successCallback, and then later you can do this:

    book.title=book.title+"more text"; // works now !
    

    I came across this issue in iOS Safari, but in Chrome and Android web-kit browsers I was able to update properties of the returned row object directly.

提交回复
热议问题