The memento pattern is an established pattern in ColdBox apps. A memento
in this case is a simple representation of your entity using arrays, structs, and simple values.
For instance, the following example shows a User entity and its corresponding memento:
You can modify the memento by overriding the getMemento
function on your entity.
The $renderData
method is a special method for ColdBox. When returning a model from a handler, this method will be called and the value returned will be used as the serialized response. This let's you simply return an entity from a handler for your API.
QuickCollection
also defines a $renderData
method, which will delegate the call to each entity in the collection and return the array of serialized entities.