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C,CAAC;GACxE;;;;;;;;;;;;oCASiB,KAAK,EAAE,KAAK,EAAE;AAC/B,UAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;GACxE;;;;;;;;;;;;oCASiB,KAAK,EAAE,KAAK,EAAE;AAC/B,UAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;GACxE;;;QAl5BqB,YAAY;IAm5BlC,CAAA","file":"QueryBuilder.js","sourcesContent":["'use strict';\n\n/** @module QueryBuilder */\nimport getArgs from 'getargs';\nimport helpers from './helpers';\nimport State from './State';\nimport QueryParser from './QueryParser';\n\nmodule.exports = class QueryBuilder {\n\t/*\n\t * SQL generation object\n\t *\n\t * @param {driver} - The syntax driver for the database\n\t * @param {adapter} - The database module adapter for running queries\n\t * @returns {QueryBuilder}\n\t * @constructor\n\t */\n\tconstructor(driver, adapter) {\n\t\tthis.driver = driver;\n\t\tthis.adapter = adapter;\n\t\tthis.parser = new QueryParser(this.driver);\n\t\tthis.state = new State();\n\t}\n\n\t/**\n\t * Complete the sql building based on the type provided\n\t *\n\t * @param {String} type\n\t * @param {String} table\n\t * @private\n\t * @return {String}\n\t */\n\t_compile(type, table) {\n\t\t// Put together the basic query\n\t\tlet sql = this._compileType(type, table);\n\n\t\t// Set each subClause\n\t\t['queryMap', 'groupString', 'orderString', 'havingMap'].forEach((clause) => {\n\t\t\tlet param = this.state[clause];\n\n\t\t\tif ( ! helpers.isScalar(param))\n\t\t\t{\n\t\t\t\tObject.keys(param).forEach((part) => {\n\t\t\t\t\tsql += param[part].conjunction + param[part].string;\n\t\t\t\t});\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tsql += param;\n\t\t\t}\n\t\t});\n\n\t\t// Append the limit, if it exists\n\t\tif (helpers.isNumber(this.state.limit))\n\t\t{\n\t\t\tsql = this.driver.limit(sql, this.state.limit, this.state.offset);\n\t\t}\n\n\t\treturn sql;\n\t}\n\n\t_compileType(type, table) {\n\t\tlet sql = '';\n\n\t\tswitch(type) {\n\t\t\tcase \"insert\":\n\t\t\t\tlet params = Array(this.state.setArrayKeys.length).fill('?');\n\n\t\t\t\tsql = `INSERT INTO ${table} (`;\n\t\t\t\tsql += this.state.setArrayKeys.join(',');\n\t\t\t\tsql += \") VALUES (\";\n\t\t\t\tsql += params.join(',') + ')';\n\t\t\tbreak;\n\n\t\t\tcase \"update\":\n\t\t\t\tsql = `UPDATE ${table} SET ${this.state.setString}`;\n\t\t\tbreak;\n\n\t\t\tcase \"delete\":\n\t\t\t\tsql = `DELETE FROM ${table}`;\n\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tsql = `SELECT * FROM ${this.state.fromString}`;\n\n\t\t\t\t// Set the select string\n\t\t\t\tif (this.state.selectString.length > 0)\n\t\t\t\t{\n\t\t\t\t\t// Replace the star with the selected fields\n\t\t\t\t\tsql = sql.replace('*', this.state.selectString);\n\t\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\treturn sql;\n\t}\n\n\t_like(field, val, pos, like, conj) {\n\t\tfield = this.driver.quoteIdentifiers(field);\n\n\t\tlike = `${field} ${like} ?`;\n\n\t\tif (pos == 'before')\n\t\t{\n\t\t\tval = `%${val}`;\n\t\t}\n\t\telse if (pos == 'after')\n\t\t{\n\t\t\tval = `${val}%`;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tval = `%${val}%`;\n\t\t}\n\n\t\tconj = (this.state.queryMap.length < 1) ? ' WHERE ' : ` ${conj} `;\n\t\tthis._appendMap(conj, like, 'like');\n\n\t\tthis.state.whereValues.push(val);\n\t}\n\n\t/**\n\t * Append a clause to the query map\n\t *\n\t * @param {String} conjunction\n\t * @param {String} string\n\t * @param {String} type\n\t * @return {void}\n\t */\n\t_appendMap(conjunction, string, type) {\n\t\tthis.state.queryMap.push({\n\t\t\ttype: type,\n\t\t\tconjunction: conjunction,\n\t\t\tstring: string\n\t\t});\n\t}\n\n\t/**\n\t * Handle key/value pairs in an object the same way as individual arguments,\n\t * when appending to state\n\t *\n\t * @private\n\t */\n\t_mixedSet(/* $letName, $valType, $key, [$val] */) {\n\t\tlet args = getArgs('$letName:string, $valType:string, $key:object|string|number, [$val]', arguments);\n\n\t\tlet obj = {};\n\n\n\t\tif (helpers.isScalar(args.$key) && !helpers.isUndefined(args.$val))\n\t\t{\n\t\t\t// Convert key/val pair to a simple object\n\t\t\tobj[args.$key] = args.$val;\n\t\t}\n\t\telse if (helpers.isScalar(args.$key) && helpers.isUndefined(args.$val))\n\t\t{\n\t\t\t// If just a string for the key, and no value, create a simple object with duplicate key/val\n\t\t\tobj[args.$key] = args.$key;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tobj = args.$key;\n\t\t}\n\n\t\tObject.keys(obj).forEach((k) => {\n\t\t\t// If a single value for the return\n\t\t\tif (['key','value'].indexOf(args.$valType) !== -1)\n\t\t\t{\n\t\t\t\tlet pushVal = (args.$valType === 'key') ? k : obj[k];\n\t\t\t\tthis.state[args.$letName].push(pushVal);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthis.state[args.$letName][k] = obj[k];\n\t\t\t}\n\t\t});\n\n\n\t\treturn this.state[args.$letName];\n\t}\n\n\t_whereMixedSet(/*key, val*/) {\n\t\tlet args = getArgs('key:string|object, [val]', arguments);\n\n\t\tthis.state.whereMap = [];\n\t\tthis.state.rawWhereValues = [];\n\n\t\tthis._mixedSet('whereMap', 'both', args.key, args.val);\n\t\tthis._mixedSet('rawWhereValues', 'value', args.key, args.val);\n\t}\n\n\t_fixConjunction(conj) {\n\t\tlet lastItem = this.state.queryMap[this.state.queryMap.length - 1];\n\t\tlet conjunctionList = helpers.arrayPluck(this.state.queryMap, 'conjunction');\n\n\t\tif (this.state.queryMap.length === 0 || ( ! helpers.regexInArray(conjunctionList, /^ ?WHERE/i)))\n\t\t{\n\t\t\tconj = \" WHERE \";\n\t\t}\n\t\telse if (lastItem.type === 'groupStart')\n\t\t{\n\t\t\tconj = '';\n\t\t}\n\t\telse\n\t\t{\n\t\t\tconj = ' ' + conj + ' ';\n\t\t}\n\n\t\treturn conj;\n\t}\n\n\t_where(key, val, defaultConj) {\n\t\t// Normalize key and value and insert into this.state.whereMap\n\t\tthis._whereMixedSet(key, val);\n\n\t\t// Parse the where condition to account for operators,\n\t\t// functions, identifiers, and literal values\n\t\tthis.state = this.parser.parseWhere(this.driver, this.state);\n\n\t\tthis.state.whereMap.forEach((clause) => {\n\t\t\tlet conj = this._fixConjunction(defaultConj);\n\t\t\tthis._appendMap(conj, clause, 'where');\n\t\t});\n\n\t\tthis.state.whereMap = {};\n\t}\n\n\t_whereNull(field, stmt, conj) {\n\t\tfield = this.driver.quoteIdentifiers(field);\n\t\tlet item = field + ' ' + stmt;\n\n\t\tthis._appendMap(this._fixConjunction(conj), item, 'whereNull');\n\t}\n\n\t_having(/*key, val, conj*/) {\n\t\tlet args = getArgs('key:string|object, [val]:string|number, [conj]:string', arguments);\n\t\targs.conj = args.conj || 'AND';\n\t\targs.val = args.val || null;\n\n\t\t// Normalize key/val and put in state.whereMap\n\t\tthis._whereMixedSet(args.key, args.val);\n\n\t\t// Parse the having condition to account for operators,\n\t\t// functions, identifiers, and literal values\n\t\tthis.state = this.parser.parseWhere(this.driver, this.state);\n\n\t\tthis.state.whereMap.forEach((clause) => {\n\t\t\t// Put in the having map\n\t\t\tthis.state.havingMap.push({\n\t\t\t\tconjunction: (this.state.havingMap.length > 0) ? ` ${args.conj} ` : ' HAVING ',\n\t\t\t\tstring: clause\n\t\t\t});\n\t\t});\n\n\t\t// Clear the where Map\n\t\tthis.state.whereMap = {};\n\t}\n\t_whereIn(/*key, val, inClause, conj*/) {\n\t\tlet args = getArgs('key:string, val:array, inClause:string, conj:string', arguments);\n\n\t\targs.key = this.driver.quoteIdentifiers(args.key);\n\t\tlet params = new Array(args.val.length);\n\t\tparams.fill('?');\n\n\t\targs.val.forEach((value) => {\n\t\t\tthis.state.whereValues.push(value);\n\t\t});\n\n\t\targs.conj = (this.state.queryMap.length > 0) ? \" \" + args.conj + \" \" : ' WHERE ';\n\t\tlet str = args.key + \" \" + args.inClause + \" (\" + params.join(',') + \") \";\n\n\t\tthis._appendMap(args.conj, str, 'whereIn');\n\t}\n\n\t_run(type, table, callback, sql, vals) {\n\n\t\tif ( ! sql)\n\t\t{\n\t\t\tsql = this._compile(type, table);\n\t\t}\n\n\t\tif ( ! vals)\n\t\t{\n\t\t\tvals = this.state.values.concat(this.state.whereValues);\n\t\t}\n\n//console.log(this.state);\n//console.log(sql);\n//console.log(vals);\n//console.log(callback);\n//console.log('------------------------');\n\n\t\t// Reset the state so another query can be built\n\t\tthis._resetState();\n\n\t\t// Pass the sql and values to the adapter to run on the database\n\t\tthis.adapter.execute(sql, vals, callback);\n\n\t}\n\n\t_getCompile(type, table, reset) {\n\t\treset = reset || false;\n\n\t\tlet sql = this._compile(type, table);\n\n\t\tif (reset) this._resetState();\n\n\t\treturn sql;\n\t}\n\n\t_resetState() {\n\t\tthis.state = new State();\n\t}\n\n\t// ----------------------------------------------------------------------------\n\t// ! Miscellaneous Methods\n\t// ----------------------------------------------------------------------------\n\n\t/**\n\t * Reset the object state for a new query\n\t *\n\t * @memberOf QueryBuilder\n\t * @return {void}\n\t */\n\tresetQuery() {\n\t\tthis._resetState();\n\t}\n\n\t/**\n\t * Returns the current class state for testing or other purposes\n\t *\n\t * @private\n\t * @return {Object}\n\t */\n\tgetState() {\n\t\treturn this.state;\n\t}\n\n\t/**\n\t * Closes the database connection for the current adapter\n\t *\n\t * @return {void}\n\t */\n\tend() {\n\t\tthis.adapter.close();\n\t}\n\n\t// ------------------------------------------------------------------------\n\t// ! Query Builder Methods\n\t// ------------------------------------------------------------------------\n\n\t/**\n\t * Specify rows to select in the query\n\t *\n\t * @memberOf QueryBuilder\n\t * @param {String|Array} fields - The fields to select from the current table\n\t * @return {QueryBuilder}\n\t */\n\tselect(fields) {\n\n\t\t// Split/trim fields by comma\n\t\tfields = (Array.isArray(fields))\n\t\t\t? fields\n\t\t\t: fields.split(\",\").map(helpers.stringTrim);\n\n\t\t// Split on 'As'\n\t\tfields.forEach((field, index) => {\n\t\t\tif (field.match(/as/i))\n\t\t\t{\n\t\t\t\tfields[index] = field.split(/ as /i).map(helpers.stringTrim);\n\t\t\t}\n\t\t});\n\n\t\tlet safeArray = this.driver.quoteIdentifiers(fields);\n\n\t\t// Join the strings back together\n\t\tsafeArray.forEach((field, index) => {\n\t\t\tif (Array.isArray(field))\n\t\t\t{\n\t\t\t\tsafeArray[index] = safeArray[index].join(' AS ');\n\t\t\t}\n\t\t});\n\n\t\tthis.state.selectString += safeArray.join(', ');\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Specify the database table to select from\n\t *\n\t * @param {String} tableName - The table to use for the current query\n\t * @return {QueryBuilder}\n\t */\n\tfrom(tableName) {\n\t\t// Split identifiers on spaces\n\t\tlet identArray = tableName.trim().split(' ').map(helpers.stringTrim);\n\n\t\t// Quote/prefix identifiers\n\t\tidentArray[0] = this.driver.quoteTable(identArray[0]);\n\t\tidentArray = this.driver.quoteIdentifiers(identArray);\n\n\t\t// Put it back together\n\t\tthis.state.fromString = identArray.join(' ');\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add a 'like/ and like' clause to the query\n\t *\n\t * @param {String} field - The name of the field to compare to\n\t * @param {String} val - The value to compare to\n\t * @param {String} [pos=both] - The placement of the wildcard character(s): before, after, or both\n\t * @return {QueryBuilder}\n\t */\n\tlike(field, val, pos) {\n\t\tthis._like(field, val, pos, ' LIKE ', 'AND');\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add a 'not like/ and not like' clause to the query\n\t *\n\t * @param {String} field - The name of the field to compare to\n\t * @param {String} val - The value to compare to\n\t * @param {String} [pos=both] - The placement of the wildcard character(s): before, after, or both\n\t * @return {QueryBuilder}\n\t */\n\tnotLike(field, val, pos) {\n\t\tthis._like(field, val, pos, ' NOT LIKE ', 'AND');\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add an 'or like' clause to the query\n\t *\n\t * @param {String} field - The name of the field to compare to\n\t * @param {String} val - The value to compare to\n\t * @param {String} [pos=both] - The placement of the wildcard character(s): before, after, or both\n\t * @return {QueryBuilder}\n\t */\n\torLike(field, val, pos) {\n\t\tthis._like(field, val, pos, ' LIKE ', 'OR');\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add an 'or not like' clause to the query\n\t *\n\t * @param {String} field - The name of the field to compare to\n\t * @param {String} val - The value to compare to\n\t * @param {String} [pos=both] - The placement of the wildcard character(s): before, after, or both\n\t * @return {QueryBuilder}\n\t */\n\torNotLike(field, val, pos) {\n\t\tthis._like(field, val, pos, ' NOT LIKE ', 'OR');\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add a 'having' clause\n\t *\n\t * @param {String|Object} key - The name of the field and the comparision operator, or an object\n\t * @param {String|Number} [val] - The value to compare if the value of key is a string\n\t * @return {QueryBuilder}\n\t */\n\thaving(/*key, [val]*/) {\n\t\tlet args = getArgs('key:string|object, [val]:string|number', arguments);\n\n\t\tthis._having(args.key, args.val, 'AND');\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add an 'or having' clause\n\t *\n\t * @param {String|Object} key - The name of the field and the comparision operator, or an object\n\t * @param {String|Number} [val] - The value to compare if the value of key is a string\n\t * @return {QueryBuilder}\n\t */\n\torHaving(/*key, [val]*/) {\n\t\tlet args = getArgs('key:string|object, [val]:string|number', arguments);\n\n\t\tthis._having(args.key, args.val, 'OR');\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set a 'where' clause\n\t *\n\t * @param {String|Object} key - The name of the field and the comparision operator, or an object\n\t * @param {String|Number} [val] - The value to compare if the value of key is a string\n\t * @return {QueryBuilder}\n\t */\n\twhere(key, val) {\n\t\tthis._where(key, val, 'AND');\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set a 'or where' clause\n\t *\n\t * @param {String|Object} key - The name of the field and the comparision operator, or an object\n\t * @param {String|Number} [val] - The value to compare if the value of key is a string\n\t * @return {QueryBuilder}\n\t */\n\torWhere(key, val) {\n\t\tthis._where(key, val, 'OR');\n\t\treturn this;\n\t}\n\n\t/**\n\t * Select a field that is Null\n\t *\n\t * @param {String} field - The name of the field that has a NULL value\n\t * @return {QueryBuilder}\n\t */\n\twhereIsNull(field) {\n\t\tthis._whereNull(field, 'IS NULL', 'AND');\n\t\treturn this;\n\t}\n\n\t/**\n\t * Specify that a field IS NOT NULL\n\t *\n\t * @param {String} field\n\t * @return {QueryBuilder}\n\t */\n\twhereIsNotNull(field) {\n\t\tthis._whereNull(field, 'IS NOT NULL', 'AND');\n\t\treturn this;\n\t}\n\n\t/**\n\t * Field is null prefixed with 'OR'\n\t *\n\t * @param {String} field\n\t * @return {QueryBuilder}\n\t */\n\torWhereIsNull(field) {\n\t\tthis._whereNull(field, 'IS NULL', 'OR');\n\t\treturn this;\n\t}\n\n\t/**\n\t * Field is not null prefixed with 'OR'\n\t *\n\t * @param {String} field\n\t * @return {QueryBuilder}\n\t */\n\torWhereIsNotNull(field) {\n\t\tthis._whereNull(field, 'IS NOT NULL', 'OR');\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set a 'where in' clause\n\t *\n\t * @param {String} key - the field to search\n\t * @param {Array} val - the array of items to search in\n\t * @return {QueryBuilder}\n\t */\n\twhereIn(key, val) {\n\t\tthis._whereIn(key, val, 'IN', 'AND');\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set a 'or where in' clause\n\t *\n\t * @param {String} key - the field to search\n\t * @param {Array} val - the array of items to search in\n\t * @return {QueryBuilder}\n\t */\n\torWhereIn(key, val) {\n\t\tthis._whereIn(key, val, 'IN', 'OR');\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set a 'where not in' clause\n\t *\n\t * @param {String} key - the field to search\n\t * @param {Array} val - the array of items to search in\n\t * @return {QueryBuilder}\n\t */\n\twhereNotIn(key, val) {\n\t\tthis._whereIn(key, val, 'NOT IN', 'AND');\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set a 'or where not in' clause\n\t *\n\t * @param {String} key - the field to search\n\t * @param {Array} val - the array of items to search in\n\t * @return {QueryBuilder}\n\t */\n\torWhereNotIn(key, val) {\n\t\tthis._whereIn(key, val, 'NOT IN', 'OR');\n\t\treturn this;\n\t}\n\n\t/**\n\t * Set values for insertion or updating\n\t *\n\t * @param {String|Object} key - The key or object to use\n\t * @param {String} [val] - The value if using a scalar key\n\t * @return {QueryBuilder}\n\t */\n\tset(/* $key, [$val] */) {\n\t\tlet args = getArgs('$key, [$val]', arguments);\n\n\t\t// Set the appropriate state variables\n\t\tthis._mixedSet('setArrayKeys', 'key', args.$key, args.$val);\n\t\tthis._mixedSet('values', 'value', args.$key, args.$val);\n\n\t\t// Use the keys of the array to make the insert/update string\n\t\t// and escape the field names\n\t\tthis.state.setArrayKeys = this.state.setArrayKeys.map(this.driver._quote);\n\n\t\t// Generate the \"set\" string\n\t\tthis.state.setString = this.state.setArrayKeys.join('=?,');\n\t\tthis.state.setString += '=?';\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Add a join clause to the query\n\t *\n\t * @param {String} table - The table you are joining\n\t * @param {String} cond - The join condition.\n\t * @param {String} [type='inner'] - The type of join, which defaults to inner\n\t * @return {QueryBuilder}\n\t */\n\tjoin(table, cond, type) {\n\t\ttype = type || \"inner\";\n\n\t\t// Prefix/quote table name\n\t\ttable = table.split(' ').map(helpers.stringTrim);\n\t\ttable[0] = this.driver.quoteTable(table[0]);\n\t\ttable = table.map(this.driver.quoteIdentifiers);\n\t\ttable = table.join(' ');\n\n\t\t// Parse out the join condition\n\t\tlet parsedCondition = this.parser.compileJoin(cond);\n\t\tlet condition = table + ' ON ' + parsedCondition;\n\n\t\t// Append the join condition to the query map\n\t\tthis._appendMap(\"\\n\" + type.toUpperCase() + ' JOIN ', condition, 'join');\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Group the results by the selected field(s)\n\t *\n\t * @param {String|Array} field\n\t * @return {QueryBuilder}\n\t */\n\tgroupBy(field) {\n\t\tif ( ! helpers.isScalar(field))\n\t\t{\n\t\t\tlet newGroupArray = field.map(this.driver.quoteIdentifiers);\n\t\t\tthis.state.groupArray = this.state.groupArray.concat(newGroupArray);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tthis.state.groupArray.push(this.driver.quoteIdentifiers(field));\n\t\t}\n\n\t\tthis.state.groupString = ' GROUP BY ' + this.state.groupArray.join(',');\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Order the results by the selected field(s)\n\t *\n\t * @param {String} field - The field(s) to order by\n\t * @param {String} [type='ASC'] - The order direction, ASC or DESC\n\t * @return {QueryBuilder}\n\t */\n\torderBy(field, type) {\n\t\ttype = type || 'ASC';\n\n\t\t// Set the fields for later manipulation\n\t\tfield = this.driver.quoteIdentifiers(field);\n\n\t\tthis.state.orderArray[field] = type;\n\n\t\tlet orderClauses = [];\n\n\t\t// Flatten key/val pairs into an array of space-separated pairs\n\t\tObject.keys(this.state.orderArray).forEach((key) => {\n\t\t\torderClauses.push(key + ' ' + this.state.orderArray[key].toUpperCase());\n\t\t});\n\n\t\t// Set the final string\n\t\tthis.state.orderString = ' ORDER BY ' + orderClauses.join(', ');\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Put a limit on the query\n\t *\n\t * @param {Number} limit - The maximum number of rows to fetch\n\t * @param {Number} [offset] - The row number to start from\n\t * @return {QueryBuilder}\n\t */\n\tlimit(limit, offset) {\n\t\tthis.state.limit = limit;\n\t\tthis.state.offset = offset || null;\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds an open paren to the current query for logical grouping\n\t *\n\t * @return {QueryBuilder}\n\t */\n\tgroupStart() {\n\t\tlet conj = (this.state.queryMap.length < 1) ? ' WHERE ' : ' AND ';\n\t\tthis._appendMap(conj, '(', 'groupStart');\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds an open paren to the current query for logical grouping,\n\t * prefixed with 'OR'\n\t *\n\t * @return {QueryBuilder}\n\t */\n\torGroupStart() {\n\t\tthis._appendMap('', ' OR (', 'groupStart');\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds an open paren to the current query for logical grouping,\n\t * prefixed with 'OR NOT'\n\t *\n\t * @return {QueryBuilder}\n\t */\n\torNotGroupStart() {\n\t\tthis._appendMap('', ' OR NOT (', 'groupStart');\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Ends a logical grouping started with one of the groupStart methods\n\t *\n\t * @return {QueryBuilder}\n\t */\n\tgroupEnd() {\n\t\tthis._appendMap('', ')', 'groupEnd');\n\n\t\treturn this;\n\t}\n\n\t// ------------------------------------------------------------------------\n\t// ! Result Methods\n\t// ------------------------------------------------------------------------\n\n\t/**\n\t * Get the results of the compiled query\n\t *\n\t * @param {String} [table] - The table to select from\n\t * @param {Number} [limit] - A limit for the query\n\t * @param {Number} [offset] - An offset for the query\n\t * @param {Function} callback - A callback for receiving the result\n\t * @return {void}\n\t */\n\tget(/* [table], [limit], [offset], callback */) {\n\t\tlet args = getArgs('[table]:string, [limit]:number, [offset]:number, callback:function', arguments);\n\n\t\tif (args.table) {\n\t\t\tthis.from(args.table);\n\t\t}\n\n\t\tif (args.limit) {\n\t\t\tthis.limit(args.limit, args.offset);\n\t\t}\n\n\t\t// Run the query\n\t\tthis._run('get', args.table, args.callback);\n\t}\n\n\t/**\n\t * Run the generated insert query\n\t *\n\t * @param {String} table - The table to insert into\n\t * @param {Object} [data] - Data to insert, if not already added with the 'set' method\n\t * @param {Function} callback - Callback for handling response from the database\n\t * @return {void}\n\t */\n\tinsert(/* table, data, callback */) {\n\t\tlet args = getArgs('table:string, [data]:object, callback:function', arguments);\n\n\t\tif (args.data) {\n\t\t\tthis.set(args.data);\n\t\t}\n\n\t\t// Run the query\n\t\tthis._run('insert', this.driver.quoteTable(args.table), args.callback);\n\t}\n\n\t/**\n\t * Insert multiple sets of rows at a time\n\t *\n\t * @param {String} table - The table to insert into\n\t * @param {Array} data - The array of objects containing data rows to insert\n\t * @param {Function} callback - Callback for handling database response\n\t * @example query.insertBatch('foo',[{id:1,val:'bar'},{id:2,val:'baz'}], callbackFunction);\n\t * @return {void}\n\t */\n\tinsertBatch(/* table, data, callback */) {\n\t\tlet args = getArgs('table:string, data:array, callback:function', arguments);\n\t\tlet batch = this.driver.insertBatch(args.table, args.data);\n\n\t\t// Run the query\n\t\tthis._run('', '', args.callback, batch.sql, batch.values);\n\t}\n\n\t/**\n\t * Run the generated update query\n\t *\n\t * @param {String} table - The table to insert into\n\t * @param {Object} [data] - Data to insert, if not already added with the 'set' method\n\t * @param {Function} callback - Callback for handling response from the database\n\t * @return {void}\n\t */\n\tupdate(/*table, data, callback*/) {\n\t\tlet args = getArgs('table:string, [data]:object, callback:function', arguments);\n\n\t\tif (args.data) {\n\t\t\tthis.set(args.data);\n\t\t}\n\n\t\t// Run the query\n\t\tthis._run('update', this.driver.quoteTable(args.table), args.callback);\n\t}\n\n\t/**\n\t * Run the generated delete query\n\t *\n\t * @param {String} table - The table to insert into\n\t * @param {Object} [where] - Where clause for delete statement\n\t * @param {Function} callback - Callback for handling response from the database\n\t * @return {void}\n\t */\n\tdelete(/*table, [where], callback*/) {\n\t\tlet args = getArgs('table:string, [where]:object, callback:function', arguments);\n\n\t\tif (args.where)\n\t\t{\n\t\t\tthis.where(args.where);\n\t\t}\n\n\t\t// Run the query\n\t\tthis._run('delete', this.driver.quoteTable(args.table), args.callback);\n\t}\n\n\t// ------------------------------------------------------------------------\n\t// ! Methods returning SQL\n\t// ------------------------------------------------------------------------\n\n\t/**\n\t * Return generated select query SQL\n\t *\n\t * @param {String} [table] - the name of the table to retrieve from\n\t * @param {Boolean} [reset=true] - Whether to reset the query builder so another query can be built\n\t * @return {String}\n\t */\n\tgetCompiledSelect(/*table, reset*/) {\n\t\tlet args = getArgs('[table]:string, [reset]:boolean', arguments);\n\t\tif (args.table)\n\t\t{\n\t\t\tthis.from(args.table);\n\t\t}\n\n\t\treturn this._getCompile('get', args.table, args.reset);\n\t}\n\n\t/**\n\t * Return generated insert query SQL\n\t *\n\t * @param {String} table - the name of the table to insert into\n\t * @param {Boolean} [reset=true] - Whether to reset the query builder so another query can be built\n\t * @return {String}\n\t */\n\tgetCompiledInsert(table, reset) {\n\t\treturn this._getCompile('insert', this.driver.quoteTable(table), reset);\n\t}\n\n\t/**\n\t * Return generated update query SQL\n\t *\n\t * @param {String} table - the name of the table to update\n\t * @param {Boolean} [reset=true] - Whether to reset the query builder so another query can be built\n\t * @return {String}\n\t */\n\tgetCompiledUpdate(table, reset) {\n\t\treturn this._getCompile('update', this.driver.quoteTable(table), reset);\n\t}\n\n\t/**\n\t * Return generated delete query SQL\n\t *\n\t * @param {String} table - the name of the table to delete from\n\t * @param {Boolean} [reset=true] - Whether to reset the query builder so another query can be built\n\t * @return {String}\n\t */\n\tgetCompiledDelete(table, reset) {\n\t\treturn this._getCompile('delete', this.driver.quoteTable(table), reset);\n\t}\n}"],"sourceRoot":"/source/"}