« get me outta code hell

linkReferencedArtworks.js « dependencies « content « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/linkReferencedArtworks.js
blob: c456b808c10e5504030cf78bd46baf72123749ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import Thing from '#thing';

export default {
  contentDependencies: [
    'linkAlbumReferencedArtworks',
    'linkTrackReferencedArtworks',
  ],

  query: (artwork) => ({
    referenceType:
      artwork.thing.constructor[Thing.referenceType],
  }),

  relations: (relation, query, artwork) => ({
    link:
      (query.referenceType === 'album'
        ? relation('linkAlbumReferencedArtworks', artwork.thing)
     : query.referenceType === 'track'
        ? relation('linkTrackReferencedArtworks', artwork.thing)
        : null),
  }),

  generate: (relations) => relations.link,
};