|
Project Information
Members
Featured
Downloads
Links
|
ColdQuery is an attempt to create a fluent interface for ColdFusion arrays and query objects. The idea was inspired by jQuery. Go to the Forums at Riaforge.org for discussion. Thanks for looking. How it works: First you initialize the ColdQuery Object with either an array, query, struct or ColdQuery object. If the object is not an array then it is converted to an array. Then you can search, sort etc.. using the ColdQuery methods. Most of the methods are chainable, so you can refine your search or sort. If you want the modified array back you can call getItems(). Currently implemented methods are: get(index) - gets the item at the index getItems() - gets the underlying array searchItems(udfString) or $(udfString) - runs the udf on each item in the array. returns all items in the array that cause the function to evaluate to true. concat(items) - appends all the items in the passed in 'items' object with the current 'items' array. If the passed in 'items' object is a not an array then it is converted to an array first. each(udfString) - runs the udf on each item in the array and replaces the item at that location with the result of the udf. writeEach(udfString) - runs the udf on each item in the array and writes the results to the page returnEachAsString() - runs the udf on each item in the array and returns the results as a string sortByColumn(expression,type,direction) - sorts the array by the expression(which can be a key name or method call) evaluating the result as the type specified(date,string,numeric) in the direction specified(asc or desc) sortByCustom(udf||udfString,direction) - runs the udf on each item in the array to determine the sort order and sorts in the direction specified(asc or desc) reverseItems() - figure it out even() - gets the even items in the array odd() - gets the odd items in the array getLength() - It's complicated I promise The udfString can be any string that evaluates to a User Defined Function. When this is complete(soon I hope) you will be able to use either an actual udf or a udfString for any method requiring a udfString. One very useful component which came out of this is the UDFCreator. It simply takes a valid udfString(cfscript or cfml definition of a udf) and generates a stand alone udf. Feel free to use it any way you like. If you make any useful changes, please let me know. More to come! |