Whatever message this page gives is out now! Go check it out!
queryFilter(query, function(row [, currentRow] [, query] ){} [, parallel] [, maxThreadCount])Parameter | Description |
query | (Required) Query to be iterated over. |
filter | (Required) Function to be called with each row of the query. Should return a boolean value. |
parallel | (Optional) True if you want to enable parallel programming. |
maxThreadCount | (Optional) The number of threads the function can execute. The number of threads must be between 1-50. If the value exceeds 50, there is an exception. |
<cfscript>
myQuery = queryNew("id,name,amount","Integer,Varchar,Integer",
[
{id=1,name="One",amount=15},
{id=2,name="Two",amount=18},
{id=3,name="Three",amount=32},
{id=4,name="Four",amount=27},
{id=5,name="Five",amount=43},
{id=6,name="Six",amount=71}
]);
filteredQuery=QueryFilter(myQuery,function(obj){
return obj.amount>=30
})
writeOutput("The filtered query is:")
writeDump(filteredQuery)
</cfscript><cfscript>
qoptions = {result="myresult", datasource="cfbookclub", fetchclientinfo="yes"};
sampleQuery = QueryExecute("select * from books order by bookid", [] ,qoptions);
function filterQuery(any Obj){
return (Obj.ISSPOTLIGHT == "Y" ? true : false);
}
WriteDump(QueryFilter(sampleQuery, filterQuery));
</cfscript><cfscript>
myResult=QueryExecute("SELECT * FROM EMPLOYEES",[],{datasource="cfdocexamples"});
// Execute the function to call each row and return the values of Location
status=myResult.filter(function (city){
return (city.LOCATION=="Newton" || city.LOCATION=="San Francisco" ? true : false);
});
// Display the values that meet the filter requirements
WriteDump(status);
</cfscript><cfscript>
myQuery = queryNew("id,name,amount","Integer,Varchar,Integer",
[
{id=1,name="One",amount=15},
{id=2,name="Two",amount=18},
{id=3,name="Three",amount=32},
{id=4,name="Four",amount=27},
{id=5,name="Five",amount=43},
{id=6,name="Six",amount=71}
]);
QueryFilter(myQuery,function(obj){
return obj.amount>=30
},true,5)
writeOutput("The filtered query is:")
//writeDump(filteredQuery)
writeDump(myQuery)
</cfscript><cfscript>
qoptions = {result="myresult", datasource="cfbookclub", fetchclientinfo="yes"};
sampleQuery = QueryExecute("select * from books order by bookid", [] ,qoptions);
writeDump(sampleQuery)
function filterQuery(any Obj){
return (Obj.ISSPOTLIGHT == "Y" ? true : false);
}
WriteDump(QueryFilter(query=sampleQuery,callback=filterQuery,parallel=true,maxthreadcount=10);
writeDump(sampleQuery);
WriteDump(QueryFilter(query=sampleQuery, callback=filterQuery,parallel=false));
writeDump(sampleQuery);
</cfscript><cfscript>
myResult=QueryExecute("SELECT * FROM EMPLOYEES",[],{datasource="cfdocexamples"});
// Execute the function to call each row and return the values of Location
status=myResult.filter(function (city){
return (city.LOCATION=="Newton" || city.LOCATION=="San Francisco" ? true : false);
},true,10);
// Display the values that meet the filter requirements
WriteDump(status);
writeDump(myResult)
</cfscript>