QueryEvery

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)

Member function

queryObj.Every(closure)

History

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 .

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

 Adobe

Get help faster and easier

New user?

Adobe MAX 2024

Adobe MAX
The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX

The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX 2024

Adobe MAX
The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX

The Creativity Conference

Oct 14–16 Miami Beach and online