11/**
2- * jSQL.js v2.9.1
3- * A Javascript Query Language Database Engine
4- * @author Robert Parham
2+ * jsql-official - v2.9.1
3+ * A persistent SQL database.
4+ * @author Rob Parham
55 * @website http://pamblam.github.io/jSQL/
6- * @license http://www.apache.org/licenses/LICENSE -2.0
6+ * @license Apache -2.0
77 */
88
99; ( function ( ) {
1010 var isNode = ! ! ( typeof module !== 'undefined' && module . exports ) ;
1111 var jSQL = ( function ( ) {
1212 "use strict" ;
1313
14- ////////////////////////////////////////////////////////////////////////////
15- // jSQL Error Handling /////////////////////////////////////////////////////
16- ////////////////////////////////////////////////////////////////////////////
17-
14+ /**
15+ * Error object constructor
16+ * @param { String } error_no
17+ */
1818 function jSQL_Error ( error_no ) {
1919 this . error = error_no ;
2020 this . stack = undefined ;
9797 return "jSQL Error #" + this . error + " - " + this . message ;
9898 } ;
9999 }
100+
100101
101102 var error_handler_function = function ( ) { } ;
102103 var mute_jsql_errors = false ;
108109 function onError ( funct ) {
109110 if ( typeof funct === "function" ) error_handler_function = funct ;
110111 }
112+
111113
112- ////////////////////////////////////////////////////////////////////////////
113- // jSQLDataTypeList ////////////////////////////////////////////////////////
114- ////////////////////////////////////////////////////////////////////////////
115-
116- function jSQLDataTypeList ( ) {
114+ function jSQLDataTypeList ( ) {
117115 this . list = [ {
118116 type : "NUMERIC" ,
119117 aliases : [ "NUMBER" , "DECIMAL" , "FLOAT" ] ,
333331 return _throw ( new jSQL_Error ( "0007" ) ) ;
334332 } ;
335333 }
336-
337- ////////////////////////////////////////////////////////////////////////////
338- // jSQL Table constructor //////////////////////////////////////////////////
339- ////////////////////////////////////////////////////////////////////////////
334+
340335
341336 function jSQLTable ( name , columns , data , types , keys , auto_increment ) {
342337 var self = this ;
612607
613608 self . init ( name , columns , data , types , keys , auto_increment ) ;
614609 }
615-
616- ////////////////////////////////////////////////////////////////////////////
617- // jSQL Query constructor //////////////////////////////////////////////////
618- ////////////////////////////////////////////////////////////////////////////
610+
619611
620612 function jSQLQuery ( type ) {
621613 var self = this ;
650642 } ;
651643 } ) ( i ) ;
652644 }
653-
654- ////////////////////////////////////////////////////////////////////////////
655- // jSQL Query Type constructors ////////////////////////////////////////////
656- ////////////////////////////////////////////////////////////////////////////
645+
657646
658647 function jSQLDeleteQuery ( ) {
659648 this . init = function ( tablename ) {
734723 return this ;
735724 } ;
736725 }
726+
737727
738728 function jSQLDropQuery ( ) {
739729 this . init = function ( tablename ) {
749739 this . fetch = function ( ) { return null ; } ;
750740 this . fetchAll = function ( ) { return [ ] ; } ;
751741 }
742+
752743
753744 function jSQLInsertQuery ( ) {
754745 this . init = function ( table ) {
780771 this . fetch = function ( ) { return null ; } ;
781772 this . fetchAll = function ( ) { return [ ] ; } ;
782773 }
774+
783775
784776 function jSQLSelectQuery ( ) {
785777 this . init = function ( columns ) {
864856 return this ;
865857 } ;
866858 }
859+
867860
868861 function jSQLUpdateQuery ( ) {
869862 this . init = function ( table ) {
10211014 this . fetchAll = function ( ) { return [ ] ; } ;
10221015 }
10231016
1024- ////////////////////////////////////////////////////////////////////////////
1025- // Parse String Query //////////////////////////////////////////////////////
1026- ////////////////////////////////////////////////////////////////////////////
1027-
10281017 function jSQLParseQuery ( query ) {
10291018
10301019 // Predcit the correct casing for column and table names
17131702 return _throw ( new jSQL_Error ( "0041" ) ) ;
17141703 }
17151704 }
1716-
1717- ////////////////////////////////////////////////////////////////////////////
1718- // Where caluse ////////////////////////////////////////////////////////////
1719- ////////////////////////////////////////////////////////////////////////////
1705+
17201706
17211707 function jSQLWhereClause ( context ) {
17221708 var self = this ;
19811967 return resultRowIndexes ;
19821968 } ;
19831969 }
1984-
1985- ////////////////////////////////////////////////////////////////////////////
1986- // Data Storage APIs ///////////////////////////////////////////////////////
1987- ////////////////////////////////////////////////////////////////////////////
1970+
19881971
19891972 var API = {
19901973
23872370
23882371 }
23892372 } ;
2390-
2391- ////////////////////////////////////////////////////////////////////////////
2392- // Persistence Manager /////////////////////////////////////////////////////
2393- ////////////////////////////////////////////////////////////////////////////
2373+
23942374
23952375 var persistenceManager = new ( function ( ) {
23962376 var self = this ;
25902570
25912571 } ) ( ) ;
25922572
2593- ////////////////////////////////////////////////////////////////////////////
2594- // Syntactic sugar /////////////////////////////////////////////////////////
2595- ////////////////////////////////////////////////////////////////////////////
2596-
25972573 function createTable ( name , columnsOrData , types , keys , auto_increment ) {
25982574
25992575 // allow for all params to be passed in a single object
26542630 if ( ! Array . isArray ( keys ) ) keys = [ keys ] ;
26552631 return new jSQLQuery ( "CREATE" ) . init ( name , columnsOrData , types , keys , auto_increment ) ;
26562632 }
2633+
26572634
26582635 function select ( cols ) {
26592636 if ( ! Array . isArray ( cols ) ) cols = [ cols ] ;
26602637 return new jSQLQuery ( "SELECT" ) . init ( cols ) ;
26612638 }
2639+
26622640
26632641 function update ( table ) {
26642642 return new jSQLQuery ( "UPDATE" ) . init ( table ) ;
26652643 }
2644+
26662645
26672646 function insertInto ( tablename ) {
26682647 return new jSQLQuery ( "INSERT" ) . init ( tablename ) ;
26712650 function dropTable ( tablename ) {
26722651 return new jSQLQuery ( "DROP" ) . init ( tablename ) ;
26732652 }
2653+
26742654
26752655 function deleteFrom ( tablename ) {
26762656 return new jSQLQuery ( "DELETE" ) . init ( tablename ) ;
26772657 }
2678-
2679- ////////////////////////////////////////////////////////////////////////////
2680- // Helper/Misc Methods /////////////////////////////////////////////////////
2681- ////////////////////////////////////////////////////////////////////////////
2658+
26822659
26832660 function jSQLReset ( ) {
26842661 jSQL . tables = { } ;
26852662 jSQL . commit ( ) ;
26862663 }
2687-
2664+
2665+
26882666 function jSQLMinifier ( sql ) {
26892667 var cleanSQL = "" ;
26902668 var lines = sql . split ( "\n" ) ;
27562734 return str ;
27572735 }
27582736
2759- ////////////////////////////////////////////////////////////////////////////
2760- // Exposed Methods /////////////////////////////////////////////////////////
2761- ////////////////////////////////////////////////////////////////////////////
2762-
27632737 return {
2764- version : 2.91 ,
2738+ version : "2.9.1" ,
27652739 tables : { } ,
27662740 query : jSQLParseQuery ,
27672741 createTable : createTable ,
27902764 window . jSQL = jSQL ;
27912765 }
27922766
2793- } ) ( ) ;
2767+ } ) ( ) ;
0 commit comments