Skip to content

Persistence Management

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

jSQL databases are stored on the user's hard drive but are loaded into memory when jSQL is loaded. For query speed, all database operations are made in memory and are not saved to the user's hard drive until jSQL.commit() is called.


jSQL.load(onLoadCallback)

Register a callback to be fired when the database has been loaded into memory and is ready to be queried.

Parameters
  • onLoadCallback: A function to be called when the database has been loaded.
Example
jSQL.load(function(){
    jSQL.createTable('Users', ['Name', `Age`]).ifNotExists().execute();
    var allUsers = jSQL.select('*').from('Users').execute().fetchAll('ASSOC');
});

jSQL.commit()

Commit any changes made to the database from memory to the user's hard drive.

Example
jSQL.dropTable('Users');
jSQL.commit();

jSQL.rollback()

Rollback any changes not yet committed.

Example
jSQL.dropTable('Users');
jSQL.rollback();

jSQL.tables

An object containing a jSQLTable object for each of your tables. If you have a table called myTable, it is located in jSQL.tables.myTable.


Clone this wiki locally