Added alias to entity search query.

This commit is contained in:
DebaucheryLibrarian 2020-10-20 00:25:32 +02:00
parent 8e7b944b52
commit 60eb599416
1 changed files with 4 additions and 4 deletions

View File

@ -174,9 +174,9 @@ async function fetchEntities(type, limit) {
} }
async function searchEntities(query, type, limit) { async function searchEntities(query, type, limit) {
const entities = knex const entities = await knex
.select(knex.raw(` .select(knex.raw(`
entities.id, entities.name, entities.slug, entities.type, entities.url, entities.description, entities.id, entities.name, entities.slug, entities.type, entities.url, entities.description, entities.alias,
COALESCE(json_agg(tags) FILTER (WHERE tags.id IS NOT NULL), '[]') as tags, COALESCE(json_agg(tags) FILTER (WHERE tags.id IS NOT NULL), '[]') as tags,
row_to_json(parents) as parent row_to_json(parents) as parent
`)) `))
@ -189,10 +189,10 @@ async function searchEntities(query, type, limit) {
.leftJoin('entities as parents', 'parents.id', 'entities.parent_id') .leftJoin('entities as parents', 'parents.id', 'entities.parent_id')
.leftJoin('entities_tags', 'entities_tags.entity_id', 'entities.id') .leftJoin('entities_tags', 'entities_tags.entity_id', 'entities.id')
.leftJoin('tags', 'tags.id', 'entities_tags.tag_id') .leftJoin('tags', 'tags.id', 'entities_tags.tag_id')
.groupBy('entities.id', 'entities.name', 'entities.slug', 'entities.type', 'entities.url', 'entities.description', 'parents.id') .groupBy('entities.id', 'entities.name', 'entities.slug', 'entities.type', 'entities.url', 'entities.description', 'entities.alias', 'parents.id')
.limit(limit || 100); .limit(limit || 100);
return curateEntities(await entities); return curateEntities(entities);
} }
async function flushEntities(networkSlugs = [], channelSlugs = []) { async function flushEntities(networkSlugs = [], channelSlugs = []) {