Posted in ColdFusion | Posted on 07-04-2011 | 2,719 views
Attached to this blog entry are new CFCs that will allow you to perform collection operations (cfcollection, cfindex, and cfsearch) view script based CFCs. From the attached zip, simply store the components in your cfinstall\customtags\com\adobe\coldfusion folder. (Make a backup of base.cfc first!!) The test files are just that - tests. They mainly work with a collection I had called 'test' so you should not expect them to work as is. They are mainly there to provide you with an example. Here are a few examples...
Collection
2c = new com.adobe.coldfusion.collection();
3
4collections = c.list();
5writedump(var=collections,label="Collections, no engine");
6
7clist = c.categoryList(collection="test");
8writedump(var=clist,label="Category list for collection test");
9
10//random name
11newname = "tempcollection_#replace(createUUID(), "-","_","all")#";
12c.create(collection=newname,path=server.coldfusion.rootdir & "/collections");
13
14writeoutput("<p>Made #newname#</p>");
15
16collections = c.list();
17writedump(var=collections,label="Collections");
18
19c.delete(collection=newname);
20
21collections = c.list();
22writedump(var=collections,label="Collections after I deleted the new one");
23
24c.optimize(collection="test");
25writeoutput("Optimized test");
26</cfscript>
Index
2//q is a query I made earlier, ditto for q2
3idx = new com.adobe.coldfusion.index();
4r = idx.refresh(collection="test",key="id",body="body",query=q,status=true);
5writeDump(var=r,label="refresh");
6
7writeoutput("size of q2 - adding - #q2.recordCount#<br/>");
8r = idx.update(collection="test",key="id",body="body",query=q2,status=true);
9writeDump(var=r,label="update");
10
11r = idx.delete(collection="test",key=1,status=true);
12writeDump(var=r,label="delete");
13
14r = idx.purge(collection="test",status=true);
15writeDump(var=r,label="purge");
16</cfscript>
Search
2mysearch = new com.adobe.coldfusion.search();
3res = mysearch.search(criteria="cfabort",collection="cfdocs",maxrows=5,status="true");
4
5writedump(var=res);
6writeoutput("<hr/>Done");
7</cfscript>


https://github.com/CFCommunity/CFScript-Community-...
Everything else in there is licensed under the MIT License, so I would hope you'd be ok licensing your stuff with that as well. MIT is nice because it allows Adobe (or anyone else) to include them in a commercial product... you know... like ColdFusion. ;)
If so, feel free to send a pull request!
https://github.com/CFCommunity/CFScript-Community-...
[Add Comment] [Subscribe to Comments]