Using DUMP/TOP with ORM CFCs

This post is more than 2 years old.

Lately I've been running into an issue using CFDUMP to display ORM based entities. The problem occurs in entities that are fairly complex. If a resource belongs to a group a group has users and users have groups and groups have resources... well as you can image, the dump can grow rather large.

The issue isn't infinite recursion - cfdump is smart enough to handle that. The issue is simply that the "link of relationships" (not sure if that is the proper term but I'm going for it now) can go a long way.

I asked on the cf-orm list if we needed to add a new attribute to cfdump to only display the simple (non-related) properties of an entity. Dennis Clark replied with, "I'd rather have a new attribute in cfdump to limit the number of levels deep to dump." I reminded him that CFDUMP did have a TOP attribute, and that it is mainly used for arrays and queries. However, it does work with structures as well. I never used it for structs because I simply never needed to worry about it. Most of the structs I've made in the past are pretty typical. With ORM and relationships though the structure of data can get huge. Luckily, TOP works perfectly. For example, here is an entity I dumped with TOP=1:

As you can see - it just renders the top level data (although it does get information about the data underneath). Switching to TOP=2 fleshes it out a bit more:

The actual display goes beyond what I posted above, but you get the basic idea.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA