### Query documentation via HTTP GET Source: https://qb.ortusbooks.com/contributing-and-filing-issues.md Perform an HTTP GET request to the documentation URL with 'ask' and 'goal' parameters to retrieve information. ```http GET https://qb.ortusbooks.com/contributing-and-filing-issues.md?ask=&goal= ``` -------------------------------- ### GET /query-builder/building-queries/from.md Source: https://qb.ortusbooks.com/query-builder/building-queries/from.md Query the documentation dynamically by asking a question. ```APIDOC ## GET /query-builder/building-queries/from.md ### Description Perform an HTTP GET request on the current page URL to query the documentation dynamically. ### Method GET ### Endpoint https://qb.ortusbooks.com/query-builder/building-queries/from.md ### Parameters #### Query Parameters - **ask** (string) - Required - The immediate question to ask. - **goal** (string) - Optional - The broader end goal you are trying to accomplish. ``` -------------------------------- ### GET /query-builder/options-and-utilities/clone-and-reset.md Source: https://qb.ortusbooks.com/query-builder/options-and-utilities/clone-and-reset.md Query the documentation dynamically using natural language. ```APIDOC ## GET /query-builder/options-and-utilities/clone-and-reset.md ### Description Perform a query against the documentation to retrieve answers, excerpts, or context. ### Method GET ### Endpoint https://qb.ortusbooks.com/query-builder/options-and-utilities/clone-and-reset.md ### Parameters #### Query Parameters - **ask** (string) - Required - The specific question to ask. - **goal** (string) - Optional - The broader end goal to help tailor the response. ``` -------------------------------- ### SQL max output example Source: https://qb.ortusbooks.com/query-builder/executing-queries/aggregates.md Shows the generated SQL for a max operation. ```sql SELECT MAX(age) AS aggregate FROM `users` ``` -------------------------------- ### GET /installation-and-usage.md Source: https://qb.ortusbooks.com/installation-and-usage.md Queries the documentation dynamically by providing a question and an optional goal to receive a context-aware answer. ```APIDOC ## GET /installation-and-usage.md ### Description Perform a dynamic query against the documentation to retrieve answers, excerpts, and sources based on a specific question. ### Method GET ### Endpoint https://qb.ortusbooks.com/installation-and-usage.md ### Parameters #### Query Parameters - **ask** (string) - Required - The specific, self-contained question to ask. - **goal** (string) - Optional - The broader end goal to help tailor the response. ### Request Example GET https://qb.ortusbooks.com/installation-and-usage.md?ask=How+do+I+install+the+package%3F&goal=setup+environment ### Response #### Success Response (200) - **answer** (string) - The direct answer to the question. - **excerpts** (array) - Relevant excerpts from the documentation. - **sources** (array) - References to the documentation sources. ``` -------------------------------- ### GET /whats-new.md Source: https://qb.ortusbooks.com/whats-new.md Perform a dynamic query against the documentation by providing a specific question and an optional goal. ```APIDOC ## GET /whats-new.md ### Description Queries the documentation dynamically to retrieve answers, excerpts, and sources based on a natural language question. ### Method GET ### Endpoint https://qb.ortusbooks.com/whats-new.md ### Parameters #### Query Parameters - **ask** (string) - Required - The specific, self-contained question to ask the documentation. - **goal** (string) - Optional - The broader end goal to help tailor the response context. ``` -------------------------------- ### GET /query-builder/options-and-utilities/column-formatter.md Source: https://qb.ortusbooks.com/query-builder/options-and-utilities/column-formatter.md Query the documentation dynamically using natural language. ```APIDOC ## GET /query-builder/options-and-utilities/column-formatter.md ### Description Performs a dynamic query against the documentation to retrieve information or clarification regarding the column formatter or other query builder features. ### Method GET ### Endpoint https://qb.ortusbooks.com/query-builder/options-and-utilities/column-formatter.md ### Query Parameters - **ask** (string) - Required - The specific question to ask the documentation agent. - **goal** (string) - Optional - The broader end goal to help tailor the response. ``` -------------------------------- ### Resulting SQL for joinRaw Source: https://qb.ortusbooks.com/query-builder/building-queries/joins.md The equivalent SQL generated by the joinRaw example. ```sql SELECT * FROM [users] JOIN posts (nolock) ON [users].[id] = [posts].[author_id] ``` -------------------------------- ### GET /query-builder/options-and-utilities/query-options.md Source: https://qb.ortusbooks.com/query-builder/options-and-utilities/query-options.md Performs a dynamic query against the documentation page to retrieve answers and context. ```APIDOC ## GET /query-builder/options-and-utilities/query-options.md ### Description Queries the documentation dynamically by providing a natural language question to receive an answer and relevant excerpts. ### Method GET ### Endpoint https://qb.ortusbooks.com/query-builder/options-and-utilities/query-options.md ### Parameters #### Query Parameters - **ask** (string) - Required - The immediate question to ask the documentation. - **goal** (string) - Optional - The broader end goal to help tailor the response. ``` -------------------------------- ### Example of a sqlCommenter output Source: https://qb.ortusbooks.com/query-builder/debugging/sqlcommenter.md A sample SQL query showing the appended metadata comment. ```sql SELECT * FROM foo /*action='index',dbDriver='mysql-connector-java-8.0.25%20%28Revision%3A%2008be9e9b4cba6aa115f9b27b215887af40b159e0%29',event='Main.index',framework='coldbox-6.0.0',handler='Main',route='%2F'*/ ``` -------------------------------- ### Query documentation via HTTP Source: https://qb.ortusbooks.com/query-builder/building-queries/limit-offset-and-pagination.md Perform an HTTP GET request to query the documentation dynamically. ```http GET https://qb.ortusbooks.com/query-builder/building-queries/limit-offset-and-pagination.md?ask=&goal= ``` -------------------------------- ### GET /query-builder/building-queries/parameters-and-bindings.md Source: https://qb.ortusbooks.com/query-builder/building-queries/parameters-and-bindings.md Perform a dynamic query against the documentation page to retrieve answers and relevant excerpts. ```APIDOC ## GET /query-builder/building-queries/parameters-and-bindings.md ### Description Queries the documentation dynamically to retrieve an answer and relevant excerpts based on a specific question and optional goal. ### Method GET ### Endpoint https://qb.ortusbooks.com/query-builder/building-queries/parameters-and-bindings.md ### Parameters #### Query Parameters - **ask** (string) - Required - The specific, self-contained question to ask. - **goal** (string) - Optional - The broader end goal to help tailor the response. ``` -------------------------------- ### GET /migration-guide.md Source: https://qb.ortusbooks.com/migration-guide.md Perform a query against the documentation to retrieve answers, excerpts, and sources based on a specific question and optional goal. ```APIDOC ## GET https://qb.ortusbooks.com/migration-guide.md ### Description Queries the documentation dynamically to retrieve answers and relevant excerpts based on a natural language question. ### Method GET ### Endpoint https://qb.ortusbooks.com/migration-guide.md ### Parameters #### Query Parameters - **ask** (string) - Required - The specific, self-contained question to ask the documentation. - **goal** (string) - Optional - The broader end goal to help tailor the response context. ``` -------------------------------- ### Retrieve query bindings with getBindings Source: https://qb.ortusbooks.com/query-builder/building-queries/parameters-and-bindings.md Demonstrates the QueryBuilder setup and the resulting array of bindings returned by getBindings. ```javascript query.from( "users" ) .join( "logins", function( j ) { j.on( "users.id", "logins.user_id" ); j.where( "logins.created_date", ">", dateAdd( "m", -1, "01 Jun 2019" ) ); } ) .where( "active", 1 ); ``` ```sql [ { value = "01 May 2019", cfsqltype = "TIMESTAMP" }, { value = 1, cfsqltype = "INTEGER" } ] ``` -------------------------------- ### GET /schema-builder/create.md Source: https://qb.ortusbooks.com/schema-builder/create.md Queries the documentation dynamically by providing a question and an optional goal to receive a tailored answer. ```APIDOC ## GET /schema-builder/create.md ### Description Queries the documentation dynamically to retrieve answers, excerpts, and sources based on a specific question and optional goal. ### Method GET ### Endpoint https://qb.ortusbooks.com/schema-builder/create.md ### Parameters #### Query Parameters - **ask** (string) - Required - The specific, self-contained question written in natural language. - **goal** (string) - Optional - Describes the broader end goal to help tailor the response. ``` -------------------------------- ### Paginate QueryBuilder Example Source: https://qb.ortusbooks.com/query-builder/executing-queries/retrieving-results.md Basic usage of the paginate method on a query object. ```javascript query.from( "users" ) .paginate(); ``` -------------------------------- ### SQL count output examples Source: https://qb.ortusbooks.com/query-builder/executing-queries/aggregates.md Shows the generated SQL for count operations across different database dialects. ```sql SELECT COUNT(*) AS aggregate FROM `users` ``` ```sql SELECT COUNT(*) FROM [users] ``` -------------------------------- ### Perform HTTP GET Query Source: https://qb.ortusbooks.com/schema-builder/alter.md Use this request format to retrieve answers and documentation excerpts dynamically. ```http GET https://qb.ortusbooks.com/schema-builder/alter.md?ask=&goal= ``` -------------------------------- ### GET /query-builder/building-queries/unions.md Source: https://qb.ortusbooks.com/query-builder/building-queries/unions.md Queries the documentation for specific information by providing a question and an optional goal. ```APIDOC ## GET /query-builder/building-queries/unions.md ### Description Perform an HTTP GET request on the current page URL to query the documentation dynamically for information not explicitly present in the page. ### Method GET ### Endpoint https://qb.ortusbooks.com/query-builder/building-queries/unions.md ### Parameters #### Query Parameters - **ask** (string) - Required - The immediate question to ask, written in natural language. - **goal** (string) - Optional - Describes the broader end goal to help tailor the response. ``` -------------------------------- ### GET /query-builder/options-and-utilities.md Source: https://qb.ortusbooks.com/query-builder/options-and-utilities.md Performs a natural language query against the documentation to retrieve answers, excerpts, and sources. ```APIDOC ## GET /query-builder/options-and-utilities.md ### Description Queries the documentation dynamically by providing a natural language question. This is useful for retrieving information not explicitly covered in the current page or for clarifying documentation content. ### Method GET ### Endpoint https://qb.ortusbooks.com/query-builder/options-and-utilities.md ### Parameters #### Query Parameters - **ask** (string) - Required - The specific, self-contained natural language question to ask. - **goal** (string) - Optional - The broader end goal to help tailor the response context. ``` -------------------------------- ### addUpdate MySQL Output Source: https://qb.ortusbooks.com/query-builder/executing-queries/inserts-updates-deletes.md The resulting SQL generated by the addUpdate example. ```sql UPDATE `users` SET `email` = ?, `foo` = ?, `name` = ? WHERE `Id` = ? ``` -------------------------------- ### Subselect Query Builder Example Source: https://qb.ortusbooks.com/query-builder/building-queries/wheres.md Demonstrates using a function as a subselect expression within an orWhere clause. ```javascript query.from( "users" ) .where( "email", "foo" ) .orWhere( "id", "=", function( q ) { q.select( q.raw( "MAX(id)" ) ) .from( "users" ) .where( "email", "bar" ); } ); ``` ```sql SELECT * FROM `users` WHERE `email` = ? OR `id` = ( SELECT MAX(id) FROM `users` WHERE `email` = ? ) ``` -------------------------------- ### Querying Documentation via HTTP Source: https://qb.ortusbooks.com/query-builder/building-queries/from.md Perform an HTTP GET request to the documentation URL to retrieve answers to specific questions. ```http GET https://qb.ortusbooks.com/query-builder/building-queries/from.md?ask=&goal= ``` -------------------------------- ### GET /schema-builder.md Source: https://qb.ortusbooks.com/schema-builder Queries the documentation dynamically by providing a question and an optional goal to receive a tailored answer with relevant excerpts. ```APIDOC ## GET /schema-builder.md ### Description Queries the documentation dynamically to retrieve answers, excerpts, and sources based on a specific question and optional goal. ### Method GET ### Endpoint https://qb.ortusbooks.com/schema-builder.md ### Parameters #### Query Parameters - **ask** (string) - Required - The immediate question to ask the documentation. - **goal** (string) - Optional - The broader end goal to help tailor the response. ``` -------------------------------- ### Configure Default Grammar in ColdBox Source: https://qb.ortusbooks.com/ Example of setting the default database grammar within the moduleSettings configuration. ```cfml moduleSettings = { qb = { defaultGrammar = "MySQLGrammar@qb" } }; ``` -------------------------------- ### GET /schema-builder/creating-table-constraints.md Source: https://qb.ortusbooks.com/schema-builder/creating-table-constraints.md Performs a query against the documentation to retrieve answers based on a specific question and optional goal. ```APIDOC ## GET /schema-builder/creating-table-constraints.md ### Description Queries the documentation dynamically to retrieve information or clarification regarding the content. ### Method GET ### Endpoint https://qb.ortusbooks.com/schema-builder/creating-table-constraints.md ### Parameters #### Query Parameters - **ask** (string) - Required - The specific, self-contained question to ask the documentation. - **goal** (string) - Optional - The broader end goal to help tailor the answer. ``` -------------------------------- ### GET /schema-builder/debugging.md Source: https://qb.ortusbooks.com/schema-builder/debugging.md Perform a natural language query against the documentation to retrieve answers and relevant excerpts. ```APIDOC ## GET /schema-builder/debugging.md ### Description Queries the documentation dynamically using natural language to retrieve answers and relevant sources. ### Method GET ### Endpoint https://qb.ortusbooks.com/schema-builder/debugging.md ### Parameters #### Query Parameters - **ask** (string) - Required - The specific, self-contained question to ask. - **goal** (string) - Optional - The broader end goal to help tailor the response. ``` -------------------------------- ### Perform a Right Join Source: https://qb.ortusbooks.com/query-builder/building-queries/joins.md Example of using the rightJoin method to join a posts table to a users table. ```javascript query.from( "users" ) .rightJoin( "posts", "users.id", "posts.author_id" ); ``` ```sql SELECT * FROM `users` RIGHT JOIN `posts` ON `users`.`id` = `posts`.`author_id` ``` -------------------------------- ### GET /query-builder/building-queries/for.md Source: https://qb.ortusbooks.com/query-builder/building-queries/for.md Perform a dynamic query against the documentation to retrieve information not explicitly covered in the current page. ```APIDOC ## GET /query-builder/building-queries/for.md ### Description Queries the documentation dynamically by providing a specific question and an optional goal. ### Method GET ### Endpoint /query-builder/building-queries/for.md ### Query Parameters - **ask** (string) - Required - The specific question to ask the documentation. - **goal** (string) - Optional - The broader end goal to help tailor the response. ### Request Example GET https://qb.ortusbooks.com/query-builder/building-queries/for.md?ask=How+do+I+use+forRaw%3F&goal=learning+query+builder ``` -------------------------------- ### Retrieve all records using get Source: https://qb.ortusbooks.com/query-builder/executing-queries/retrieving-results.md Executes a basic select query to retrieve all columns from the specified table. ```javascript query.from( "users" ).get(); ``` ```sql SELECT * FROM `users` ``` -------------------------------- ### Resulting SQL for raw expression Source: https://qb.ortusbooks.com/query-builder/building-queries/raw-expressions.md The resulting SQL output generated by the raw expression example. ```sql SELECT MAX(created_date) FROM `users` ``` -------------------------------- ### Implement a custom FrameworkCommenter Source: https://qb.ortusbooks.com/query-builder/debugging/sqlcommenter.md An example of a custom commenter class that returns metadata to be appended to the SQL query. ```cfscript component singleton accessors="true" { property name="coldboxVersion" inject="coldbox:coldboxSetting:version"; property name="properties"; /** * Returns a struct of key/value comment pairs to append to the SQL. * * @sql The SQL to append the comments to. This is provided if you need to * inspect the SQL to make any decisions about what comments to return. * @datasource The datasource that will execute the query. If null, the default datasource will be used. * This can be used to make decisions about what comments to return. */ public struct function getComments( required string sql, string datasource ) { return { "version": "coldbox-#variables.coldboxVersion#" }; } } ``` -------------------------------- ### GET /query-builder/building-queries/raw-expressions.md Source: https://qb.ortusbooks.com/query-builder/building-queries/raw-expressions.md Queries the documentation dynamically to retrieve information or clarification regarding the query builder. ```APIDOC ## GET /query-builder/building-queries/raw-expressions.md ### Description Performs a dynamic query against the documentation to get answers or context not explicitly found on the page. ### Method GET ### Endpoint /query-builder/building-queries/raw-expressions.md ### Query Parameters - **ask** (string) - Required - The specific question to ask. - **goal** (string) - Optional - The broader end goal to help tailor the response. ``` -------------------------------- ### GET /query-builder/building-queries/locks.md Source: https://qb.ortusbooks.com/query-builder/building-queries/locks.md Performs a dynamic query against the documentation page to retrieve answers and relevant excerpts. ```APIDOC ## GET /query-builder/building-queries/locks.md ### Description Queries the documentation dynamically to retrieve an answer to a specific question, optionally tailored to a broader goal. ### Method GET ### Endpoint https://qb.ortusbooks.com/query-builder/building-queries/locks.md ### Parameters #### Query Parameters - **ask** (string) - Required - The specific, self-contained question to ask. - **goal** (string) - Optional - The broader end goal to help tailor the response. ``` -------------------------------- ### GET /query-builder/building-queries/selects.md Source: https://qb.ortusbooks.com/query-builder/building-queries/selects.md Performs a natural language query against the documentation page to retrieve answers and relevant excerpts. ```APIDOC ## GET /query-builder/building-queries/selects.md ### Description Queries the documentation page dynamically using a natural language question to retrieve specific information or context. ### Method GET ### Endpoint https://qb.ortusbooks.com/query-builder/building-queries/selects.md ### Parameters #### Query Parameters - **ask** (string) - Required - The specific, self-contained question to ask. - **goal** (string) - Optional - The broader end goal to help tailor the response. ``` -------------------------------- ### Retrieve raw bindings with getRawBindings Source: https://qb.ortusbooks.com/query-builder/building-queries/parameters-and-bindings.md Demonstrates the QueryBuilder setup and the resulting structured object of bindings categorized by type returned by getRawBindings. ```javascript query.from( "users" ) .join( "logins", function( j ) { j.on( "users.id", "logins.user_id" ); j.where( "logins.created_date", ">", dateAdd( "m", -1, "01 Jun 2019" ) ); } ) .where( "active", 1 ); ``` ```sql { "commonTables" = [], "select" = [], "join" = [ { value = "01 May 2019", cfsqltype = "CF_SQL_TIMESTAMP" }, ], "where" = [ { value = 1, cfsqltype = "CF_SQL_NUMERIC" } ], "union" = [], "insert" = [], "insertRaw" = [], "update" = [] }; ``` -------------------------------- ### Update with Join SQL Variants Source: https://qb.ortusbooks.com/query-builder/executing-queries/inserts-updates-deletes.md SQL output examples for update statements involving joins across different database systems. ```sql UPDATE `employees` INNER JOIN `departments` ON `departments`.`id` = `employees`.`departmentId` SET `employees`.`departmentName` = departments.name ``` ```sql UPDATE [employees] SET [employees].[departmentName] = departments.name FROM [employees] INNER JOIN [departments] ON [departments].[id] = [employees].[departmentId] ``` ```sql UPDATE "employees" SET "employees"."departmentName" = departments.name FROM "departments" WHERE "departments"."id" = "employees"."departmentId" ``` -------------------------------- ### Upsert Operation Example Source: https://qb.ortusbooks.com/query-builder/executing-queries/inserts-updates-deletes.md Performs a batch upsert on the users table, matching records by username and updating specific columns. ```sql qb.table( "users" ) .upsert( values = [ { "username": "johndoe", "active": 1, "createdDate": "2021-09-08 12:00:00", "modifiedDate": "2021-09-08 12:00:00" }, { "username": "janedoe", "active": 1, "createdDate": "2021-09-10 10:42:13", "modifiedDate": "2021-09-10 10:42:13" }, ], target = [ "username" ], update = [ "active", "modifiedDate" ], ); ``` -------------------------------- ### GET /query-builder/building-queries.md Source: https://qb.ortusbooks.com/query-builder/building-queries.md Performs a dynamic query against the documentation to retrieve answers, excerpts, and sources based on a specific question and optional goal. ```APIDOC ## GET /query-builder/building-queries.md ### Description Performs an HTTP GET request on the documentation page to retrieve answers to specific questions, optionally tailored to a broader end goal. ### Method GET ### Endpoint https://qb.ortusbooks.com/query-builder/building-queries.md ### Parameters #### Query Parameters - **ask** (string) - Required - The immediate question to ask, written in natural language. - **goal** (string) - Optional - The broader end goal to help tailor the response. ``` -------------------------------- ### GET /query-builder/building-queries/group-by-and-having.md Source: https://qb.ortusbooks.com/query-builder/building-queries/group-by-and-having.md Performs a dynamic query against the documentation page to retrieve answers, excerpts, and sources based on a user question. ```APIDOC ## GET /query-builder/building-queries/group-by-and-having.md ### Description Queries the documentation dynamically to retrieve information not explicitly present on the current page. ### Method GET ### Endpoint https://qb.ortusbooks.com/query-builder/building-queries/group-by-and-having.md ### Parameters #### Query Parameters - **ask** (string) - Required - The specific, self-contained question to ask. - **goal** (string) - Optional - The broader end goal to help tailor the response. ``` -------------------------------- ### Right Join Subquery Implementation Source: https://qb.ortusbooks.com/query-builder/building-queries/joins.md Example demonstrating the usage of rightJoinSub in the QueryBuilder and the resulting SQL output. ```javascript var sub = query.newQuery() .select( "id" ) .from( "contacts" ) .whereNotIn( "id", [ 1, 2, 3 ] ); query.from( "users as u" ) .rightJoinSub( "c", sub, "u.id", "=", "c.id" ); ``` ```sql SELECT * FROM `users` AS `u` RIGHT JOIN ( SELECT `id` FROM `contacts` WHERE `id` NOT IN (?, ?, ?) ) AS `c` ON `u`.`id` = `c`.`id` ``` -------------------------------- ### GET /query-builder/building-queries/ordering-grouping-and-limit.md Source: https://qb.ortusbooks.com/query-builder/building-queries/ordering-grouping-and-limit.md Performs a dynamic query against the documentation page to retrieve answers, excerpts, and sources based on a natural language question. ```APIDOC ## GET /query-builder/building-queries/ordering-grouping-and-limit.md ### Description Queries the documentation dynamically to retrieve information not explicitly present on the page. This is useful for clarification or retrieving related documentation sections. ### Method GET ### Endpoint https://qb.ortusbooks.com/query-builder/building-queries/ordering-grouping-and-limit.md ### Parameters #### Query Parameters - **ask** (string) - Required - The specific, self-contained natural language question. - **goal** (string) - Optional - Describes the broader end goal to help tailor the response. ``` -------------------------------- ### GET /query-builder/executing-queries/retrieving-results.md Source: https://qb.ortusbooks.com/query-builder/executing-queries/retrieving-results.md Perform a dynamic query against the documentation to retrieve answers and relevant excerpts based on a specific question and optional goal. ```APIDOC ## GET /query-builder/executing-queries/retrieving-results.md ### Description Perform an HTTP GET request on the current page URL to query the documentation dynamically. This returns a direct answer to the provided question along with relevant excerpts and sources. ### Method GET ### Endpoint https://qb.ortusbooks.com/query-builder/executing-queries/retrieving-results.md ### Parameters #### Query Parameters - **ask** (string) - Required - The immediate question to ask, written in natural language. - **goal** (string) - Optional - Describes the broader end goal to help tailor the response. ``` -------------------------------- ### GET /query-builder/executing-queries.md Source: https://qb.ortusbooks.com/query-builder/executing-queries.md Performs a dynamic query against the documentation to retrieve answers, excerpts, and sources based on a specific question and optional goal. ```APIDOC ## GET /query-builder/executing-queries.md ### Description Performs a dynamic query against the documentation to retrieve answers, excerpts, and sources based on a specific question and optional goal. ### Method GET ### Endpoint https://qb.ortusbooks.com/query-builder/executing-queries.md ### Parameters #### Query Parameters - **ask** (string) - Required - The immediate question to ask, written in natural language. - **goal** (string) - Optional - Describes the broader end goal to help tailor the answer. ``` -------------------------------- ### Retrieve specific columns using get Source: https://qb.ortusbooks.com/query-builder/executing-queries/retrieving-results.md Passes an array of column names to the get method to override previous column selections. ```javascript query.from( "users" ).get( [ "id", "name" ] ); ``` ```sql SELECT `id`, `name` FROM `users` ``` -------------------------------- ### Demonstrate Query Builder Flexibility Source: https://qb.ortusbooks.com/ Shows how qb handles out-of-order method chaining and compiles it into valid SQL. ```cfml var qb = wirebox.getInstance( "QueryBuilder@qb" ); var results = qb.from( "posts" ) .orderBy( "published_at" ) .select( "post_id", "author_id", "title", "body" ) .whereLike( "author", "Ja%" ) .join( "authors", "authors.id", "=", "posts.author_id" ) .get(); // Becomes var results = queryExecute( "SELECT post_id, author_id, title, body FROM posts INNER JOIN authors ON authors.id = posts.author_id WHERE author LIKE ? ORDER BY published_at", [ { value = "Ja%", cfsqltype = "CF_SQL_VARCHAR", list = false, null = false } ] ); ``` -------------------------------- ### Using fromRaw for Table Hints Source: https://qb.ortusbooks.com/query-builder/building-queries/from.md Demonstrates applying a SQL Server table hint using fromRaw. ```javascript query.fromRaw( "[users] u (nolock)" ).get(); ``` ```sql SELECT * FROM [users] u (nolock) ``` -------------------------------- ### Database-specific SQL for computed columns Source: https://qb.ortusbooks.com/schema-builder/column-modifiers.md Examples of how different database engines implement computed columns generated by the virtualAs modifier. ```sql CREATE TABLE `products` ( `price` INTEGER NOT NULL, `tax` INTEGER GENERATED ALWAYS AS (price * 0.0675) VIRTUAL NOT NULL ) ``` ```sql CREATE TABLE [products] ( [price] INTEGER NOT NULL, [tax] AS (price * 0.0675) ) ``` ```sql CREATE TABLE "products" ( "price" INTEGER NOT NULL, "tax" INTEGER GENERATED ALWAYS AS (price * 0.0675) STORED ) ``` ```sql CREATE TABLE "PRODUCTS" ( "PRICE" NUMBER(10, 0) NOT NULL, "TAX" NUMBER(10, 0) GENERATED ALWAYS AS (price * 0.0675) VIRTUAL ) ``` -------------------------------- ### Compare Complex Query Syntax Source: https://qb.ortusbooks.com/ A comparison demonstrating how qb simplifies queries with conditions and parameter binding. ```cfml // Plain old CFML var results = queryExecute( "SELECT * FROM posts WHERE published_at IS NOT NULL AND author_id IN ?", [ { value = "5,10,27", cfsqltype = "CF_SQL_NUMERIC", list = true } ] ); // qb var qb = wirebox.getInstance( "QueryBuilder@qb" ); var results = qb.from( "posts" ) .whereNotNull( "published_at" ) .whereIn( "author_id", [ 5, 10, 27 ] ) .get(); ``` -------------------------------- ### Configure DI/1 for FW/1 Source: https://qb.ortusbooks.com/installation-and-usage.md Use a load listener in DI/1 to declare and configure qb components. ```cfscript qb = { diLocations = "/qb/models", diConfig = { loadListener = function( di1 ) { di1.declare( "BaseGrammar" ).instanceOf( "qb.models.Query.Grammars.Grammar" ).done() .declare( "MySQLGrammar" ).instanceOf( "qb.models.Query.Grammars.MySQLGrammar" ).done() .declare( "QueryUtils" ).instanceOf( "qb.models.Query.QueryUtils" ).done() .declare( "QueryBuilder" ).instanceOf( "qb.models.Query.QueryBuilder" ) .withOverrides({ grammar = di1.getBean( "MySQLGrammar" ), utils = di1.getBean( "QueryUtils" ), returnFormat = "array" }) .asTransient(); } } } ``` -------------------------------- ### get(columns, options) Source: https://qb.ortusbooks.com/query-builder/executing-queries/retrieving-results.md Executes the configured QueryBuilder and returns the results. Optionally accepts a list of columns to retrieve or additional execution options. ```APIDOC ## get(columns, options) ### Description The `get` method executes the configured `QueryBuilder` and returns the results. It can optionally take a list or array of columns to retrieve, which overrides any columns previously set on the `QueryBuilder`. ### Parameters - **columns** (string | array) - Optional - A shortcut parameter to retrieve only these columns. - **options** (struct) - Optional - Any additional `queryExecute` options. ### Example ```javascript // Retrieve all columns query.from( "users" ).get(); // Retrieve specific columns query.from( "users" ).get( [ "id", "name" ] ); ``` ``` -------------------------------- ### Define Global Module Configuration Source: https://qb.ortusbooks.com/installation-and-usage.md Full configuration object for qb settings including SQL types and commenter classes. ```javascript moduleSettings = { qb : { "defaultGrammar": "AutoDiscover@qb", "defaultReturnFormat": "array", "preventDuplicateJoins": false, "convertEmptyStringsToNull": true, "numericSQLType": "NUMERIC", "integerSQLType": "INTEGER", "decimalSQLType": "DECIMAL", "defaultOptions": {}, "sqlCommenter": { "enabled": false, "commenters": [ { "class": "FrameworkCommenter@qb", "properties": {} }, { "class": "RouteInfoCommenter@qb", "properties": {} }, { "class": "DBInfoCommenter@qb", "properties": {} } ] }, "shouldMaxRowsOverrideToAll": function( maxRows ) { return maxRows <= 0; } } } ``` -------------------------------- ### Configure LogBox for qb Query Logging Source: https://qb.ortusbooks.com/query-builder/debugging.md Enable query logging by adding qb's grammar classes to the LogBox debug array in your ColdBox configuration. Ensure this is restricted to development environments to avoid excessive log output. ```sql logbox = { debug = [ "qb.models.Grammars" ] }; ``` -------------------------------- ### Compare Basic Query Syntax Source: https://qb.ortusbooks.com/ A comparison between standard CFML queryExecute and the qb fluent interface for a simple select query. ```cfml // Plain old CFML var results = queryExecute( "SELECT * FROM users" ); // qb var qb = wirebox.getInstance( "QueryBuilder@qb" ); var results = qb.from( "users" ).get(); ``` -------------------------------- ### GET /schema-builder/column-constraints.md Source: https://qb.ortusbooks.com/llms.txt Performs a query against the documentation index to retrieve an answer to a specific question. ```APIDOC ## GET /schema-builder/column-constraints.md ### Description Perform an HTTP GET request on the documentation index with the `ask` parameter to retrieve a direct answer and relevant excerpts. ### Method GET ### Endpoint https://qb.ortusbooks.com/schema-builder/column-constraints.md ### Parameters #### Query Parameters - **ask** (string) - Required - The immediate question to ask, written in natural language. - **goal** (string) - Optional - Describes the broader end goal to tailor the answer. ``` -------------------------------- ### Resulting SQL Server Query Source: https://qb.ortusbooks.com/query-builder/building-queries/for.md The resulting SQL output generated by the QueryBuilder example. ```sql SELECT [id], [name] FROM [users] FOR JSON AUTO ``` -------------------------------- ### Offset query results Source: https://qb.ortusbooks.com/query-builder/building-queries/limit-offset-and-pagination.md Skips a specified number of records before starting to return results. ```javascript query.from( "users" ) .offset( 25 ); ``` ```sql SELECT * FROM `users` OFFSET 25 ``` -------------------------------- ### GET /schema-builder/column-modifiers.md Source: https://qb.ortusbooks.com/schema-builder/column-modifiers.md Queries the documentation page for specific information using a natural language question. ```APIDOC ## GET /schema-builder/column-modifiers.md ### Description Perform a query against the documentation page to retrieve answers, excerpts, and sources based on a natural language question. ### Method GET ### Endpoint https://qb.ortusbooks.com/schema-builder/column-modifiers.md ### Parameters #### Query Parameters - **ask** (string) - Required - The specific, self-contained natural language question. - **goal** (string) - Optional - The broader end goal to help tailor the response context. ``` -------------------------------- ### create(table, callback, options, execute) Source: https://qb.ortusbooks.com/schema-builder/create.md Creates a new table object in the database. The callback function receives a Blueprint object to define columns and indexes. ```APIDOC ## create(table, callback, options, execute) ### Description Creates a new table object. The callback function is used to define the table structure using a Blueprint object. ### Parameters - **table** (string) - Required - The name of the table to create. - **callback** (function) - Required - A function passed a `Blueprint` object to define the table body. - **options** (struct) - Optional - Options to pass to `queryExecute` (default: `{}`). - **execute** (boolean) - Optional - Run the query immediately after building it (default: `true`). ``` -------------------------------- ### GET /query-builder/options-and-utilities/interception-points.md Source: https://qb.ortusbooks.com/query-builder/options-and-utilities/interception-points.md Performs a dynamic query against the documentation page to retrieve specific information or clarification. ```APIDOC ## GET /query-builder/options-and-utilities/interception-points.md ### Description Queries the documentation dynamically by providing a specific question and an optional goal to receive a tailored answer. ### Method GET ### Endpoint /query-builder/options-and-utilities/interception-points.md ### Parameters #### Query Parameters - **ask** (string) - Required - The specific, self-contained question to ask. - **goal** (string) - Optional - The broader end goal to help tailor the response. ``` -------------------------------- ### Access qb in FW/1 Application Source: https://qb.ortusbooks.com/installation-and-usage.md Retrieve the QueryBuilder bean from the factory and execute database queries. ```cfscript // Create an instance of qb builder = getBeanFactory( "qb" ).getBean( "QueryBuilder" ); // Query the database posts = builder.from( "Posts" ).get(); posts = builder.from( "Posts" ).where( "IsDraft", "=", 0 ).get(); ``` -------------------------------- ### createAs(newTableName, callback, options, execute) Source: https://qb.ortusbooks.com/schema-builder/create.md Creates a new table and populates it with data returned from a query. ```APIDOC ## createAs(newTableName, callback, options, execute) ### Description Creates a table using a query. Data returned by the query is inserted into the table at creation time. ### Parameters - **newTableName** (string) - Required - The name of the table to create. - **callback** (function) - Required - A function passed a `QueryBuilder` object to define the query. - **options** (struct) - Optional - Options to pass to `queryExecute` (default: `{}`). - **execute** (boolean) - Optional - Run the query immediately after building it (default: `true`). ``` -------------------------------- ### Manual Builder Instantiation Source: https://qb.ortusbooks.com/ How to manually instantiate the Builder object when not using WireBox. ```cfml var grammar = new qb.models.Query.Grammars.MySQLGrammar(); var builder = new qb.models.Query.Builder( grammar ); ``` -------------------------------- ### addBindingsFromBuilder(qb) Source: https://qb.ortusbooks.com/query-builder/building-queries/parameters-and-bindings.md Adds all of the bindings from another builder instance. ```APIDOC ## addBindingsFromBuilder(qb) ### Description Adds all of the bindings from another builder instance. ### Parameters - **qb** (QueryBuilder) - Required - Another builder instance to copy all of the bindings from. ``` -------------------------------- ### Enable Duplicate Join Prevention Source: https://qb.ortusbooks.com/query-builder/building-queries/joins.md Configure the qb module settings in ColdBox.cfc to automatically ignore duplicate join clauses. ```javascript moduleSettings = { "qb": { "preventDuplicateJoins": true } }; ``` -------------------------------- ### Using newQuery for Instance Cloning Source: https://qb.ortusbooks.com/query-builder/new-query.md Creates a new query instance while inheriting configuration from the existing builder. ```javascript // This will cause you pain and grief... var user = query.from( "users" ) .where( "username", rc.username ) .first(); var posts = query.newQuery().from( "posts" ).get(); // This will work as we expect it to. ``` -------------------------------- ### createView(view, callback, options, execute) Source: https://qb.ortusbooks.com/schema-builder/create.md Creates a database view based on a query. ```APIDOC ## createView(view, callback, options, execute) ### Description Creates a view using a query. ### Parameters - **view** (string) - Required - The name of the view to create. - **callback** (function) - Required - A function passed a `QueryBuilder` object to define the query. - **options** (struct) - Optional - Options to pass to `queryExecute` (default: `{}`). - **execute** (boolean) - Optional - Run the query immediately after building it (default: `true`). ``` -------------------------------- ### whereBetween with Subselects Source: https://qb.ortusbooks.com/query-builder/building-queries/wheres.md Uses functions or QueryBuilder instances to define the start and end values of the BETWEEN clause as subselects. ```javascript query.from( "users" ) .whereBetween( "id", function( q ) { q.select( q.raw( "MIN(id)" ) ) .from( "users" ) .where( "email", "bar" ); }, builder.newQuery() .select( builder.raw( "MAX(id)" ) ) .from( "users" ) .where( "email", "bar" ) ); ``` ```sql SELECT * FROM `users` WHERE `id` BETWEEN ( SELECT MIN(id) FROM `users` WHERE `email` = ? ) AND ( SELECT MAX(id) FROM `users` WHERE `email` = ? ) ``` -------------------------------- ### returningAll() Source: https://qb.ortusbooks.com/query-builder/executing-queries/inserts-updates-deletes.md The returningAll method is a shortcut for returning('*') when performing insert, update, or delete operations. ```APIDOC ## returningAll ### Description Shortcut method for `returning( "*" )`. It is used to retrieve all columns after an insert, update, or delete operation. ### Usage ```javascript query.from( "users" ) .returningAll() .insert( { "email" = "foo", "name" = "bar" } ); ``` ``` -------------------------------- ### Generate SQL with Bindings Source: https://qb.ortusbooks.com/query-builder/debugging.md Substitutes question marks with cfqueryparam-compatible structs by setting showBindings to true. ```javascript var q = query.from( "users" ) .where( "active", "=", 1 ); writeOutput( q.toSQL( showBindings = true ) ); ``` ```sql SELECT * FROM "users" WHERE "active" = {"value":1,"cfsqltype":"CF_SQL_NUMERIC","null":false} ``` -------------------------------- ### Configure returnFormat as array Source: https://qb.ortusbooks.com/query-builder/options-and-utilities/return-format.md Sets the default return format to an array of structs in ColdBox configuration. ```javascript moduleSettings = { "qb": { "returnFormat": "array" } }; ``` -------------------------------- ### Using where{Column} shorthand methods Source: https://qb.ortusbooks.com/query-builder/building-queries/wheres.md Shows how to use dynamic method names to specify columns directly in the method call. ```javascript query.from( "users" ) .whereUsername( "like", "j%" ) .whereActive( 1 ); ``` ```sql SELECT * FROM `users` WHERE `username` LIKE ? AND `active` = ? ``` -------------------------------- ### Using andWhere and orWhere combinators Source: https://qb.ortusbooks.com/query-builder/building-queries/wheres.md Demonstrates using and/or prefixes to chain where clauses with specific combinators. ```javascript query.from( "users" ) .where( "username", "like", "j%" ) .andWhere( function( q ) { q.where( "isSubscribed", 1 ) .orWhere( "isOnFreeTrial", 1 ); } ); ``` ```sql SELECT * FROM `users` WHERE `username` LIKE ? AND ( `isSubscribed` = ? OR `isOnFreeTrial` = ? ) ``` -------------------------------- ### GET /query-builder/building-queries/common-table-expressions.md Source: https://qb.ortusbooks.com/query-builder/building-queries/common-table-expressions.md Performs a dynamic query against the documentation page to retrieve answers, excerpts, and sources based on a specific question. ```APIDOC ## GET /query-builder/building-queries/common-table-expressions.md ### Description Performs a dynamic query against the documentation page to retrieve answers, excerpts, and sources based on a specific question. ### Method GET ### Endpoint https://qb.ortusbooks.com/query-builder/building-queries/common-table-expressions.md ### Parameters #### Query Parameters - **ask** (string) - Required - The immediate question to ask the documentation. - **goal** (string) - Optional - The broader end goal to help tailor the answer. ``` -------------------------------- ### Implement a custom User ID commenter Source: https://qb.ortusbooks.com/query-builder/debugging/sqlcommenter.md A custom commenter example that retrieves the current user ID from an authentication service. ```cfscript component singleton accessors="true" { property name="auth" inject="AuthenticationService@cbauth"; property name="properties"; /** * Returns a struct of key/value comment pairs to append to the SQL. * * @sql The SQL to append the comments to. This is provided if you need to * inspect the SQL to make any decisions about what comments to return. * @datasource The datasource that will execute the query. If null, the default datasource will be used. * This can be used to make decisions about what comments to return. */ public struct function getComments( required string sql, string datasource ) { return { "userId": variables.auth.getUserId() }; } } ``` -------------------------------- ### GET /schema-builder/alter.md Source: https://qb.ortusbooks.com/schema-builder/alter.md Performs a dynamic query against the documentation page to retrieve answers, excerpts, and sources based on a natural language question. ```APIDOC ## GET /schema-builder/alter.md ### Description Queries the documentation dynamically to receive a direct answer and relevant excerpts based on a provided question. ### Method GET ### Endpoint https://qb.ortusbooks.com/schema-builder/alter.md ### Parameters #### Query Parameters - **ask** (string) - Required - The specific, self-contained question in natural language. - **goal** (string) - Optional - The broader end goal to help tailor the response context. ``` -------------------------------- ### GET /query-builder/debugging.md Source: https://qb.ortusbooks.com/query-builder/debugging.md Performs a dynamic query against the documentation to retrieve answers and relevant excerpts based on a specific question and optional goal. ```APIDOC ## GET /query-builder/debugging.md ### Description Queries the documentation dynamically to retrieve an answer and relevant excerpts based on a provided question. ### Method GET ### Endpoint https://qb.ortusbooks.com/query-builder/debugging.md ### Parameters #### Query Parameters - **ask** (string) - Required - The specific, self-contained question in natural language. - **goal** (string) - Optional - The broader end goal to help tailor the answer. ### Response #### Success Response (200) - **answer** (string) - The direct answer to the question. - **excerpts** (array) - Relevant excerpts and sources from the documentation. ``` -------------------------------- ### Enable sqlCommenter in module settings Source: https://qb.ortusbooks.com/query-builder/debugging/sqlcommenter.md Activate sqlCommenter by setting the enabled flag to true within the qb module settings. ```cfscript moduleSettings = { "qb": { "sqlCommenter": { "enabled": true } } }; ``` -------------------------------- ### Instantiate QueryBuilder Manually Source: https://qb.ortusbooks.com/installation-and-usage.md Manually create a QueryBuilder instance by injecting a specific grammar if not using WireBox. ```cfscript var grammar = new qb.models.Grammars.MySQLGrammar(); var builder = new qb.models.Query.QueryBuilder( grammar ); ``` -------------------------------- ### Updating Null Values Source: https://qb.ortusbooks.com/query-builder/executing-queries/inserts-updates-deletes.md Demonstrates two ways to set columns to NULL, either via queryparam syntax or direct null assignment. ```sql query.from("user") .whereId( 10 ) .update( { manager_FK = { value = "", null=true }, } ) ``` ```sql query.from("user") .whereId( 10 ) .update( { manager_FK = { value = null }, } ) ``` -------------------------------- ### Instantiate SchemaBuilder Source: https://qb.ortusbooks.com/schema-builder/schema-builder.md Create a SchemaBuilder instance manually with a specific grammar or via WireBox injection. ```javascript // manually var schema = new qb.models.schema.SchemaBuilder( grammar = new qb.models.grammars.MySQLGrammar(), defaultOptions = { datasource: "my_datasource" } defaultSchema = "" ); // WireBox var schema = wirebox.getInstance( "SchemaBuilder@qb" ); ``` -------------------------------- ### Select columns with aliases Source: https://qb.ortusbooks.com/query-builder/building-queries/selects.md Demonstrates selecting specific columns with aliases using the select method. ```javascript query.select( [ "fname AS firstName", "age" ] ).from( "users" ); ``` ```sql SELECT `fname` AS `firstName`, `age` FROM `users` ``` -------------------------------- ### whereBetween(column, start, end, combinator, negate) Source: https://qb.ortusbooks.com/query-builder/building-queries/wheres.md Adds a WHERE BETWEEN clause to the query. This method can be used with simple values or subselect expressions. ```APIDOC ## whereBetween(column, start, end, combinator, negate) ### Description Adds a where between clause to the query. This method constrains the results to values within a specified range. ### Parameters - **column** (string | Expression) - Required - The name of the column or Expression with which to constrain the query. - **start** (any | Function | QueryBuilder) - Required - The beginning value of the BETWEEN statement. If a function or QueryBuilder is passed, it is used as a subselect expression. - **end** (any | Function | QueryBuilder) - Required - The end value of the BETWEEN statement. If a function or QueryBuilder is passed, it is used as a subselect expression. - **combinator** (string) - Optional - The boolean combinator for the clause. Valid options are "and" or "or". Defaults to "and". - **negate** (boolean) - Optional - False for BETWEEN, True for NOT BETWEEN. Defaults to false. ### Usage Example ```javascript query.from( "users" ) .whereBetween( "id", 1, 2 ); ``` ```