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

1
QuerySome(query,closure)

Member function

1
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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<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("" & QuerySome(myquery,doesPersonExist)) // Returns True
</cfscript>

Output

NO
YES