Spec-Zone.ru › ColdFusion

querySome

This function calls a given closure/function with every element in a given query and returns true, if one of the closure calls returns true

querySome(query, function(row [, currentRow] [, query] ){} [, parallel] [, maxThreads]) → returns boolean

Member Function Syntax

query.some(function(row [, currentRow] [, query] ){} [, parallel] [, maxThreads])

  • CF2018.0.5+
  • Lucee
  • BL 1.0.0+
  • See Also: queryFilter queryReduce queryMap

    Argument Reference

    query query
    Required

    query to filter entries from

    callback boolean
    Required

    Closure or a function reference that will be called for each of the iteration.

    Callback parameters:

    • row* struct : A struct with all of the columns for the current iteration
    • currentRow* numeric : The value for the current iteration
    • query* query : A reference of the original struct

    parallel boolean
    Default: false

    Lucee 4.5+ true if the items can be executed in parallel
    Values:
    • true
    • false

    maxThreads numeric
    Default: 20

    Lucee 4.5+ the maximum number of threads to use when parallel = true

    Links more information about querySome

    • Map, Reduce and other Higher Order Functions - A Primer for map, reduce, filter, and Higher Order Functions in general.

    Examples
    Sample code invoking the querySome function

    The simple Querysome example

    Here,we've example to check whether the 75 is exists or not in myquery mark column value.

    <cfscript>
    myQuery = queryNew("id,name,mark","integer,varchar,integer",[[1,"Rahu",75],[2,"Ravi",80]]);
     result = querySome(myQuery , function(details){
    	 return details.mark IS 75;
     });
     writeOutput((result ? "Some" : "No") & " matches  Record found!");
    </cfscript>

    Expected Result: Some matches Record found!

    The Query Member Function example

    Here,we've example to check whether the 85 is exists or not in myquery mark column value using query member function.

    <cfscript>
    myQuery = queryNew("id,name,mark","integer,varchar,integer",[[1,"Rahu",75],[2,"Ravi",80]]);
     result = myQuery.Some(function(details){
    	 return details.mark IS 85;
     });
     writeOutput((result ? "Some" : "No") & " matches  Record found!");
    </cfscript>

    Expected Result: No matches Record found!

    © 2012–present Foundeo, Inc. and the CFDocs contributors.
    Licensed under the MIT License.
    ColdFusion is a trademark of Adobe Systems Incorporated.
    https://cfdocs.org/querysome

    Spec-Zone.ru

    Настройки Оффлайн Что нового Помощь О нас
    Spec-Zone .ru
    спецификации, руководства, описания, API