« get me outta code hell

linkReferencingArtworks.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/linkReferencingArtworks.js
blob: 0cfca4dbbc9ae489383f3cf9480c9956093f3030 (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: [
    'linkAlbumReferencingArtworks',
    'linkTrackReferencingArtworks',
  ],

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

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

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