Spec-Zone.ru › ColdFusion

queryMap

Maps each query row using a function to manipulate the rows fields

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

Member Function Syntax

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

  • CF2016+
  • Lucee
  • BL 1.0.0+
  • See Also: queryFilter queryReduce querySome queryEach

    Argument Reference

    query query
    Required

    query to process 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 queryMap

    • Map, Reduce and other Higher Order Functions - A Primer for map, reduce, filter, and Higher Order Functions in general.
    • ColdFusion 2016: query iteration functions - A look at the higher-order functions that queries have

    Examples
    Sample code invoking the queryMap function

    Maps query results

    Manipulates query column

    news = queryNew("id,title",
    	"integer,varchar", [{
    		"id": 1,
    		"title": "Dewey defeats Truman"
    	}, {
    		"id": 2,
    		"title": "Man walks on Moon"
    	}]
    );
    
    writeDump(news);
    
    function mapQuery(any Obj) {
    	if (Obj.id == 1)
    		Obj.title = "NEW: " & Obj.title;
    	return Obj;
    }
    
    newQuery = QueryMap(news, mapQuery);
    writeDump(newQuery);

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

    Spec-Zone.ru

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