Reputation: 63
I found Worklight JSONStore has no size limit by Worklight runtime. Does WL JSONStore API return error/error code if you add to collection and hit the size limit of your mobile device?
Upvotes: 0
Views: 368
Reputation: 5111
Yes, you should get an error, but it will be a generic one like PERSISTENT_STORE_FAILURE
(-1
). I recommend testing this as part of your regular unit, funcional, etc. tests and QA process for your application. Report back if you see something unexpected.
Recently I answered a similar question "Can the JSON offline device store be size restricted?". I'll add my answer here because I believe it could be helpful.
While this functionality is not baked into the core API, it should be fairly straightforward to implement.
JSONStore has an enhance method you can use to add functions to the JSONStoreInstance prototype. There's an example inside that should help.
Cordova has a File API
Note: "size: The size of the file in bytes. (long)"
JSONStore stores its data here:
[app]/Documents/wljsonstore/jsonstore.sqlite
/data/data/com.[app-name]/databases/wljsonstor/jsonstore.sqlite
I talked a bit about that file in these StackOverflow answers:
Check the file size of jsonstore.sqlite
using Cordova's File API before you add more data to your JSONStore collection.
Basically you would do something like this:
if(checkFileSize(collection.name+'.sqlite') < LIMIT){
collection.add(...);
}
Using enhance you can wrap that logic into its own method (e.g. collection.addWithSizeCheck(....)
) that checks the file size and calls collection.add(...)
.
Note that the default username is jsonstore
, hence jsonstore.sqlite
. If you pass a username to init it will create a new .sqlite file with that username.
Upvotes: 2