-
Notifications
You must be signed in to change notification settings - Fork 7
Helper Methods
Rob Parham edited this page Dec 28, 2017
·
2 revisions
jSQL has a few helper methods that may also be helpful to you, so it exposes them on the jSQL object.
Delete all tables and then commit the changes to the persistence manager.
jSQL.reset();
Remove SQL comments, extra spaces, tabs, linebreaks from a jSQL string.
var sql = jSQL.minify('-- A Create Query Template \
CREATE TABLE IF NOT EXISTS `myTable` \
( `String` VARCHAR(20), \
`Number` INT \
)');
// returns: 'CREATE TABLE IF NOT EXISTS `myTable` ( `String` VARCHAR(20), `Number` INT )'
Export your jSQL database. Useful for transferring data to a MySQL database.
- export_tables: If true or undefined, output a "CREATE TABLE" statement as well, else only output data
- table_names: An array of tables to export. If not defined, will export all of them.
var sql_dump = jSQL.export();
Import your jSQL database. Basically this is just a helper function that splits several statements delimited by ;\n
and runs them one at a time. This will break if the table data contains the ;\n
string.
var sql_dump = jSQL.import(sql_dump);
jSQLTable.name
jSQLTable.columns
jSQLTable.data
jSQLTable.colmap
jSQLTable.renameColumn
jSQLTable.addColumn
jSQLTable.loadData
jSQLTable.insertRow
jSQLQuery.ifNotExists
jSQLQuery.ignore
jSQLQuery.execute
jSQLQuery.fetch
jSQLQuery.fetchAll
jSQLQuery.values
jSQLQuery.set
jSQLQuery.where
jSQLQuery.from
jSQLQuery.limit
jSQLQuery.orderBy
jSQLQuery.asc
jSQLQuery.desc
jSQLQuery.distinct
jSQLWhereClause.where
jSQLWhereClause.equals
jSQLWhereClause.preparedLike
jSQLWhereClause.doesNotEqual
jSQLWhereClause.lessThan
jSQLWhereClause.contains
jSQLWhereClause.endsWith
jSQLWhereClause.beginsWith
jSQLWhereClause.and
jSQLWhereClause.or
jSQLWhereClause.limit
jSQLWhereClause.orderBy
jSQLWhereClause.asc
jSQLWhereClause.desc
jSQLWhereClause.execute