QueryEvery

Note:

You can also set the maximum thread count in ColdFusion Administrator. Click Server Settings > Settings and specify the number of threads in Default Maximum Thread Count For Parallel Functions.

Description

Determines if all values of a query satisfy a given condition.

Returns

True if all values match a condition; false, otherwise.

Syntax

queryEvery(query, closure [, parallel] [, maxThreadCount])

Member function

queryObj.Every(closure)

History

ColdFusion (2021 release): Introduced the following parameters:

  • parallel
  • maxThreadCount

New in ColdFusion (2018 release) Update 5.

Parameters

Parameter

Required/Optional

Description

struct

Required

Query in which all values are to be searched.

closure

Required

Function that encapsulates criteria.

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.

Example

Example 1

<cfscript> 
 myQuery=queryNew([ 
  {"Id":101,"Name":"John Adams","Contract":"Permanent"}, 
  {"Id":102,"Name":"Jason Adams","Contract":"Temp"}, 
  {"Id":103,"Name":"Jack Adams","Contract":"Temp"}, 
  {"Id":104,"Name":"James Adams","Contract":"Permanent"} 
 ]); 
 doesPersonExist=(obj)=>return obj.contract=="Permanent"  
 writeOutput(QueryEvery(myquery,doesPersonExist)) // Returns False 
</cfscript>

Output

NO

Example 2

<cfscript>
 myQuery=queryNew([
  {"Id":101,"Name":"John Adams","Contract":"Permanent"},
  {"Id":102,"Name":"Jason Adams","Contract":"Permanent"},
  {"Id":103,"Name":"Jack Adams","Contract":"Permanent"},
  {"Id":104,"Name":"James Adams","Contract":"Permanent"}
 ]);
 doesPersonExist=(obj)=>return obj.contract=="Permanent" 
 writeOutput(QueryEvery(myquery,doesPersonExist)) // Returns True
</cfscript>

Output

YES

Using parallelization

<cfscript> 
    myQuery=queryNew([ 
        {"Id":101,"Name":"John Adams","Contract":"Permanent"}, 
        {"Id":102,"Name":"Jason Adams","Contract":"Permanent"}, 
        {"Id":103,"Name":"Jack Adams","Contract":"Permanent"}, 
        {"Id":104,"Name":"James Adams","Contract":"Permanent"} 
    ]); 
    doesPersonExist=(obj)=>return obj.contract=="Permanent" 
    writeOutput(QueryEvery(myquery,doesPersonExist,true,5)) // Returns True 
</cfscript>

Get help faster and easier

New user?