Now that you have created your entities, how do we use them? Well, you will be using them from your handlers or other services by leveraging WireBox's getInstance() method. You can use entityNew() as well, but if you do, you will loose any initial dependency injection within the entity. This is a ColdFusion limitation where we can't listen for new entity constructions. If you want to leverage DI, as best practice retrieve everything from WireBox.

Once you have an instance of the entity, then you can use it to satisfy your requirements with the entire gamut of functions available from the base services.

Tip: You can also check out our Basic CRUD guide for an initial overview of the usage.

    function index( event, rc, prc ){
        var user = getInstance( "User" ); = user.list( sortOrder="fname" ); = user.list( sortOrder="fname", asStream=true );
    function count( event, rc, prc ){
        return getInstance( "User" ).count()
        return getInstance( "User" ).countWhere( { isActive : true } );
    function show( event, rc, prc ){
        return getInstance( "User" )
            .getOrFail( 123 )
            .when( rc.isActive, (user) => user.checkIfActive() )
    function save( event, rc, prc ){
        return populateModel( model="User", composeRelationships=true )
    function delete( event, rc, prc ){
        getInstance( "User" )
            .getOrFail( ?: -1 )
        return "User Deleted";


Last updated