Skip to content

Storage APIs

Rob Parham edited this page Sep 25, 2017 · 2 revisions

There are currently 5 ways jSQL can store data. If you're using Node, it will always use the filesystem API to store raw data in a file called .jsqldatastore, otherwise jSQL will attempt to use one of four other available APIs: indexedDB, WebSQL, localStorage or cookies - in that order. jSQL provides methods for you to prioritize which APIs are tried first and for you to see which one is actually used.


jSQL.setApiPriority(api [,...])

Change the default API priority order. This method must be called before jSQL.load().

Parameters

Pass it the name of the APIs you want to use in the order you want them tried. API names are: indexedDBAPI, WebSQLAPI, localStorageAPI, cookieAPI.

Example
jSQL.setApiPriority('localStorageAPI', 'WebSQLAPI');

jSQL.getApi()

Get the name of the API that is being used. Will return any of these: indexedDBAPI, WebSQLAPI, localStorageAPI, cookieAPI. This method must be called after jSQL has loaded (ie, inside the jSQL.load() callback.

Example
jSQL.load(function(){
    alert("jSQL is storing your data in: "+jSQL.getApi());
});

Clone this wiki locally