Show Menu
Cheatography

Quick ORM (CFML) Cheat Sheet by

Quick is an ORM library for Coldfusion/Lucee built by Eric Peterson from Ortus Solutions. Code: https://github.com/coldbox-modules/quick Docs: https://quick.ortusbooks.com/

Query Methods

var user = getInstance( "User" )
    .where( "active", 1 )
    .whereActive( 1 ); // dynamic
    .whereBetween( "id", 1, 2 );
    .whereColumn( "products.id", "orders.id" );
    .whereExists( existsQuery );
    .whereIn( "id", [ 1, 4, 66 ] );
    .whereLike( "username", "J%" );
    .whereNotNull( "publishedDate" )
    .whereNull( "id" );
    .orWhere( "email", "LIKE", q & "%" );
----------------------------------
    .orderByDesc( "username" )
    .orderBy( "modified_date", "desc" );  
    .orderByRaw( "CASE WHEN status = ? THEN 1 ELSE 0 END DESC", [ 1 ] );
    .orderByActive() // dynamic
----------------------------------
    .take( 5 );
    .offset( 25 );
    .limit( 10 )
    .asMemento()
    .asTransient()
    .select( "name", "email", "createdDate" );
    .addSelect( [ "fname AS firstName", "age" ] ).from( "users" );
    .selectRaw( "YEAR(birthdate) AS birth_year" ).from( "users" );
----------------------------------
    .all();
    .existsOrFail( rc.userID );
    .existsOrFail( rc.userID );
    .find( rc.userID );
    .findOrCreate( rc.id, { "name" : "nada" });
    .findOrFail( rc.userID );
    .findOrNew( rc.id, { "name" : "nada" });
    .first();
    .firstOrCreate( { "username": rc.username } );
    .firstOrFail();
    .firstOrNew( { "username": rc.username } );
    .firstWhere( "username", rc.username );
    .forPage( 3, 15 );
    .get();
    .getMemento();
    .paginate( rc.page, rc.maxrows ); 
    .simplePaginate( rc.page, rc.maxrows );
    .toList( chr( 10 ) );
    .toSQL( showBindings = true ) );
----
    .updateAll();
    .update();
    .save();
    .deleteAll( [ 4, 10, 22 ] );
----------------------------------
Hydration
    .hydrate({ "id": 4, "name": "JaneDoe" }); r.isLoaded(); // true
    .hydrateAll([{ "id": 4, "name": "JaneDoe" },{ "id": 5, "name": "BobDoe" }]);
Here's my note
 

Cheats­heets

For full QB and Quick cheats­heets click the link below:

https:­//t­ims­ays­hey.gi­thu­b.i­o/c­fml­-ch­eat­sheets/
               
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          RedBeanPHP Class Reference Cheat Sheet
          ColdFusion CFScript Cheat Sheet
          ColdFusion Member Functions Cheat Sheet