queryMap
Maps each query row using a function to manipulate the rows fields
queryMap(query, function(row [, currentRow] [, query] ){} [, parallel] [, maxThreads]) → returns query
Member Function Syntax
query.map(function(row [, currentRow] [, query] ){} [, parallel] [, maxThreads])
Argument Reference
query query Required
query to process entries from
callback boolean Required
Closure or a function reference that will be called for each of the iteration.
Callback parameters:
-
row* struct : A struct with all of the columns for the current iteration -
currentRow* numeric : The value for the current iteration -
query* query : A reference of the original struct
parallel boolean
Default: false
false
Lucee 4.5+ true if the items can be executed in parallel
Values:
truefalse
maxThreads numeric
Default: 20
20
Lucee 4.5+ the maximum number of threads to use when parallel = true
Links more information about queryMap
- Map, Reduce and other Higher Order Functions - A Primer for map, reduce, filter, and Higher Order Functions in general.
- ColdFusion 2016: query iteration functions - A look at the higher-order functions that queries have
Examples Sample code invoking the queryMap function
Manipulates query column
news = queryNew("id,title",
"integer,varchar", [{
"id": 1,
"title": "Dewey defeats Truman"
}, {
"id": 2,
"title": "Man walks on Moon"
}]
);
writeDump(news);
function mapQuery(any Obj) {
if (Obj.id == 1)
Obj.title = "NEW: " & Obj.title;
return Obj;
}
newQuery = QueryMap(news, mapQuery);
writeDump(newQuery);
© 2012–present Foundeo, Inc. and the CFDocs contributors.
Licensed under the MIT License.
ColdFusion is a trademark of Adobe Systems Incorporated.
https://cfdocs.org/querymap