Custom collection

Need to implement a custom behavior for your collections ?

Although the aurelia-collection Collection class provide most common CRUD functionalities, it is sometime necessary to implement your own behavior in your collections.

An example can be the need to adress a specific endpoint that goes beyond creation/suppression of your model.

1. Collection custom implementation

You simply need to extends Collection class.

class MyCollection extends Collection { isComplete(model) { // optionnaly return a boolean, to tell if the provided model has all its field populated. } refKeys() { // optionnaly return an array that describe the mapping between model backend attribute names and frontend attribute names. } /* your methods that do specific collection manipulations here */ }

isComplete and refKeys are two methods that handle sub-models population.