Allowing entity to be fetched by alias.

This commit is contained in:
DebaucheryLibrarian 2020-10-20 00:21:15 +02:00
parent cb459d4cc7
commit 6b17f9d1f2
2 changed files with 4 additions and 1 deletions

View File

@ -6,6 +6,7 @@ const parentNetworks = [
slug: 'gamma',
name: 'Gamma Entertainment',
url: 'https://www.gammaentertainment.com',
alias: ['gammaentertainment'],
},
{
slug: 'hush',

View File

@ -20,6 +20,7 @@ function curateEntity(entity, includeParameters = false) {
description: entity.description,
slug: entity.slug,
type: entity.type,
aliases: entity.alias,
parent: curateEntity(entity.parent, includeParameters),
} : {};
@ -132,8 +133,9 @@ async function fetchEntity(entityId, type) {
if (type) {
queryBuilder
.where('entities.type', type)
.where('entities.slug', entityId)
.where('entities.type', type);
.orWhere(knex.raw(':entityId = ANY(entities.alias)', { entityId }));
return;
}