cordova-sqlite-dbfile-plugin
v1.1.0
Published
Connect to sqlite file and interact with it
Downloads
3
Maintainers
Readme
Sqlite File plugin
A simple plugin to access to a Sqlite File in the device (Not to a sqlite db instantiated in the device nor to create one)
Contributors are welcome.
Platforms supported
- android
- iOS (Partial)
Installation
cordova plugin add cordova-sqlite-file-plugin
Easy Use
The object JJdbFile
is expose in the window
:
Methonds
read(options, async, successCallback, errorCallback)
options
{Object} -- useSqlFile: {Boolean} - Define if use a SQL file or a SQL string
- sqlFilePath: {String} - Path to the SQL file (By now is relative to the asset folder)
- queryParams: {Array} - Params to replaces in the SQL sentence
- multiple: {Boolean} - If true, split the sentence in each
;
and execute in order
async
{Boolean} - Define if should use the main thread or notsuccessCallback
{Function} - Function to call in plugin successerrorCallback
{Function} - Function to call in plugin fail
execute(options, async, successCallback, errorCallback)
options
{Object} -- useSqlFile: {Boolean} - Define if use a SQL file or a SQL string
- sqlFilePath: {String} - Path to the SQL file (By now is relative to the asset folder)
- queryParams: {Array(String|Number)} - Params to replaces in the SQL sentence
- multiple: {Boolean} - If true, split the sentence in each
;
and execute in order
async
{Boolean} - Define if should use the main thread or notsuccessCallback
{Function} - Function to call in plugin success- Params:
- response: {Object} -
- success: {Boolean} -
- data: {Any} -
- message: {String} -
- response: {Object} -
- Params:
errorCallback
{Function} - Function to call in plugin fail
Use Example
To Read
var dbFile = new JJdbFile("path/to/db/file");
dbFile.read({
useSqlFile : true
sqlFilePath : "Path/To/SQL/File"
queryParams : []
multiple : false
}, true, function(response){
if(response.success){
console.log("All Ok")
}
console.log("Not Ok, success false")
}, function(){
console.log("Not Ok, fail")
})
There is a big TODO list, but in resume
- Write a better documentation
- Support the queries file locations in others locations and not just assets
- Allow to use SQL sentence (Not just file)
- It could be valid to connect with an instance (Thinking)