QuerySome

Description

Determines if at least one value in a query satisfies a specified condition.

Returns

True if at least one value matches a condition; false, otherwise.

Syntax

QuerySome(query,closure)

Member function

queryObj.Some(closure)

History

New in ColdFusion (2018 release) Update 5.

Parameters

Parameter

Required/Optional

Description

query

Required

Query in which at least one value is to be searched.

closure

Required

Function that encapsulates  criteria .

Example

<cfscript> 
    myQuery=queryNew([ 
        {"Id":101,"Name":"John"}, 
        {"Id":102,"Name":"Jason"}, 
        {"Id":103,"Name":"Jack"}, 
        {"Id":104,"Name":"James"} 
    ]); 
    // First closure to check for Jim 
    doesPersonExist=(obj)=>return obj.name=="Jim" 
    writeOutput(QuerySome(myquery,doesPersonExist)) // Returns False 
    // Second closure to check for James 
    doesPersonExist=(obj)=>return obj.name=="James" 
    writeOutput("<br/>" & QuerySome(myquery,doesPersonExist)) // Returns True 
</cfscript>

Output

NO
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