Configuration

Let's see how to configure the plugin

Collections must be registred and configured at plugin loading time. You can configure each collection to :

  • Give it a unique key that is used to inject the collection where you need it (see Using a Collection)
  • Address a specific api on your endpoint
  • Specify the type of collection class with your custom behavior
  • Specify the type of model class your collection is going to handle
  • Set the unique id property name of your model object

1. Basic configuration

This is the most basic settings you can have to register a collection :

aurelia.use
   /* Your other plugins and init code */
   .plugin('aurelia-collection', config => {
    // will handle object literals with a provided Collection class instance, 
    // that use '/api/SomeBasic/' as API default route.
    config.registerCollection('SomeBasic');
   });

2. Custom collection & model configuration

Most of the time, you will want to implement your custom collection and model behavior, declare them like this :

import { SomeModel } from '/path/to/your/implementation.model';
import { SomeCollection } from '/path/to/your/implementation.collection';

aurelia.use
   /* Your other plugins and init code */
   .plugin('aurelia-collection', config => {
     config.registerCollection('Some', '/api/someDefaultEndpoint/', SomeCollection, SomeModel);
   });

What’s Next

Use a collection