Search code examples
javascripthtmlindexeddbweb-sqlydn-db

Can YDN-DB handle large entries at once?


Im having troubles trying to retrieve a large amount of data using Ydn-db.

The problem is:

-I have a large JSon file that I want to store in my app to use it offline

-I query the file and then save the data successfully using db.put

-Then, if I "print" the stored data using db.values, I only get a portion of the text I previously saved.

You can also test it usign the Todo list demo given as an example here: http://dev.yathit.com/demo/ydn-db/todo.html

If you enter, lets say a 1MB text in the input, you wont get the whole text saved but just a fraction of it.

Is there a way to get around this issue?

Thanks!

EDIT: Here is a working example of what Im talking about http://flatic.com/test.html

EDIT 2: Ok, I think I found a temporary solution, it looks like YDN-DB can't store more than 100 Json objects so instead of saving my Json data directly like:

db.put('table',largeJsonData);

I first put the largeJsonData as string inside a simple Json Array, something like this:

var data = {
"json":largeJsonData
};

db.put('table',data);

Now I can read the data doing:

db.values('table').done(function(items) {
console.log(items[0].json);
});

But you wont be able to make index search or get a specific value by any given Id


Solution

  • Please prove your claim by a simple test. I don't think browser limit to 1mb per record. If fail, it fail whole. Partial commit is just impossible.

    If websql, may be lost during JSON serialization. Possible. Haven't tested.

    EDIT after question update.

    Your data is not text, you parse it - and becomes array of JSON objects. db.put will insert them individually as a separate record. db.values has 100 records limit. If you put a limit on db.values('todo', null, 100000), you should get all.

    100 limit is common surprise for user. I hate surprise on API. But still I feel there should be a limit on that method.