lore-hook-collections

Creates a Collection for each model in the application

lore-hook-collections

Source code for this hook can be found on GitHub at this link.

Purpose

Iterates through all models in lore.models and creates a corresponding Collection for each of them. This is done so we can fetch collections of resources and not just individual resources.

This hook isn't meant to be interacted with directly at the moment. While there are things you could do with it, the use cases for needing to do so are not clear.

Config

module.exports = {

  /**
   * While this file can influence the behavior of collections, there is currently
   * no clear reason why you would ever need to use it.
   *
   * If you need to define collection specific behavior (such as parsing server responses
   * or defining headers to add to requests) you should do that in 'config/connections.js'.
   *
   * If you have multiple connections, and need to define which collections use each
   * connection, you should do that in 'config/models.js' as this file inherits that
   * behavior.
   *
   */

};

Example Usage

This hook generates the collections that are used by the find action to communicate with the API server and retrieve a list of resources.

For example, given a tweet model, and assuming the apiRoot for the default connection is set tohttps://api.example.com, the code below will produce an API call to https://api.example.com/tweets?user=1

var collection = new lore.collections.tweet();

collection.fetch({
  data: {
    user: 1
  }
});