CF Snippets

Return query as array

You may find manipulating an array object easier than manipulating a query object. Using the returntype option, you can ask queryExecute() to return an array for functional-style processing on that query data.

var usernames = queryExecute( 
  "SELECT id,name FROM users",
  {},
  { "returntype": "array" }
);
// Now we can use closures on the result
var newUsernames = usernames
  .filter( user => user.name CONTAINS "Born" )
  .each( user => user.name.replace( "Born", "Bourne" );