memento
in this case is a simple representation of your entity using arrays, structs, and simple values.this.memento
struct on the entity and passing in arguments to the getMemento
function.includes
. You can change this or add other Mementifier options by defining your own this.memento
struct on your entity. Your custom this.memento
struct will be merged with Quick's default, so you can only define what changes you need.instanceReady()
lifecycle method in this example because retrieveAttributeNames()
relies on the entity being wired (though not loaded); it is not otherwise necessary to put this.memento
inside instanceReady()
.getMemento
arguments.getMemento
function on your entity. In this case, a $getMemento
function will be available which is the Mementifier function.getMemento
yourself or mapping over the array of results returned by calling asMemento
before executing the query. asMemento
takes the same arguments that getMemento
does. It will pass those arguments on and convert your entities to mementos after executing the query. This works for all the query execution methods - find
, first
, get
, paginate
, etc.$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. By default this will call getMemento()
.QuickCollection
also defines a $renderData
method, which will delegate the call to each entity in the collection and return the array of serialized entities.QuickCollection
as your entity's newCollection
.