Search…
Return Format
returnFormat refers to the transformation your executed query makes (if any) before being returned to you. You can choose one of three return formats:
    "array"
    "query"
    A custom function
By default, qb returns an array of structs as the result of your query. This is the same as specifying array as your returnFormat:
config/ColdBox.cfc
1
moduleSettings = {
2
"qb": {
3
"returnFormat": "array"
4
}
5
};
Copied!
You can get the original query object that CFML generates by setting the returnFormat to query:
config/ColdBox.cfc
1
moduleSettings = {
2
"qb": {
3
"returnFormat": "query"
4
}
5
};
Copied!
This setting can be overridden on a per-instance basis by calling setReturnFormat():
setReturnFormat
1
var qb = wirebox.getInstance( "[email protected]" );
2
3
qb
4
.setReturnFormat( 'query' )
5
.from( 'users' )
6
.get()
Copied!
If you want complete control over your return result, you can provide a function as a returnFormat. The results of the function will be returned as the results of the builder.
config/ColdBox.cfc
1
moduleSettings = {
2
"qb": {
3
"returnFormat": function( q ) {
4
return application.wirebox.getInstance(
5
"name" = "Collection",
6
"initArguments" = { "collection": q }
7
);
8
}
9
}
10
};
Copied!
Last modified 10mo ago
Copy link