Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface AggregationGenerator<T1, T2, T3, T4>

Defines how Aggregator will aggregate information from a resource.

remarks

See AlbumAggregator for an example implementations of this interface. It must be exported as a simple object instead of a class, so its methods can be called staticly (static interface methods are not supported by typescript). This needs to be the case so normalization/aggregation calls to methods can be called without instantiating a new class instance, which is very useful.

Type parameters

Hierarchy

  • AggregationGenerator

Index

Properties

aggregationType

aggregationType: AggregationType

Optional flatFields

flatFields: string[]

Methods

convertFromRaw

  • convertFromRaw(entity: T1): T2

Optional encode

  • encode(flatAggregation: T4): Promise<T3>

Optional flatten

  • flatten(aggregation: T2, entity?: DatabaseEntities, spotifyId?: string): Promise<T4>

generateFromEntity

  • generateFromEntity(entity: T1, normalized: boolean, spotifyId?: string): Promise<T2>
  • Aggregates data for an Aggregation. Implementations consist of two steps

    1. Ensure all necessary aggregation data is contained in Aggregator.entity, fetching it if not found.
    2. Load all of this data into appropriate Aggregation (to be returned)

    Parameters

    • entity: T1
    • normalized: boolean

      if data in returned aggregation should be normalized using [[Aggregator.normalize]]

    • Optional spotifyId: string

    Returns Promise<T2>

normalize

  • normalize(aggregation: T2): T2

template

  • template(defaultVal: number): T2

Generated using TypeDoc