A WebSQL / SQLite wrapper for web and cross platform mobile applications.
Simple include sqlava.js in your head.
<script src="sqlava.js"></script>
Creating a database using sqLava is very simple:
sqLava.initDB({
name:'myDatabase',
version:1,
size:25,
callback:function(r){console.log(r);},
debug:true,
jslogic:false
});
Creating tables is also very simple:
sqLava.create({
table:'arrayTable',
columns:"column1,column2"
});
Success and error callback handlers can also be included in the parameter object. The parameter within the callback handlers is the SQLResultSet object associated to the transaction.
sqLava.create({
table:'arrayTable',
columns:"column1,column2",
success:function(r){alert("Success!")},
error:function(r){alert("Error!")
});
To insert data, you simple provide an array representing each row you'd like to add:
sqLava.insert({
table:'myTable',
"rows":[
{
"column1": "FirstRow",
"column2": "SecondColumn"
},
{
"column1": "FirstColumn",
"column2": {
set:"date()",
func:true
}
}
]
});
sqLava simplifies and reduces the code associated with database transactions. It allows you to perform transactions without writting any SQL or transaction calls. You simply pass in the data you want to add / change / remove and it handles the rest.
It can handle all common database queries
- Creating tables
- Inserting into tables
- Inserting JSON into tables
- Performing Select queries
- Updating tables
- Deleting from tables
- Exporting tables as JSON, CSV
- Analysing tables rows, columns
- Toggling between JavaScript and SQL logic
Examples of these operations can be found in example.js.
The browsers which ship with WebSQL are listed here: https://caniuse.com/#feat=sql-storage.
However, most importantly, sqLava / WebSQL can be used in the development of cross platform mobile applications (Cordova).