Skip to content

Commit

Permalink
fix: Change query to use alises
Browse files Browse the repository at this point in the history
  • Loading branch information
LautaroPetaccio committed Mar 11, 2022
1 parent 294b5eb commit be1b1c8
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Item/Item.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ export class Item extends Model<ItemAttributes> {
}

static findByThirdPartyIds(thirdPartyIds: string[]) {
const itemsTable = raw(this.tableName)
const collectionsTable = raw(Collection.tableName)

return this.query<ItemAttributes>(SQL`
SELECT ${itemsTable}.*
FROM ${itemsTable}
JOIN ${collectionsTable} ON ${collectionsTable}.id = ${itemsTable}.collection_id
WHERE ${collectionsTable}.third_party_id = ANY(${thirdPartyIds})`)
SELECT items.*
FROM ${raw(this.tableName)} items
JOIN ${raw(
Collection.tableName
)} collections ON collections.id = items.collection_id
WHERE collections.third_party_id = ANY(${thirdPartyIds})`)
}

static findOrderedByCollectionId(
Expand Down

0 comments on commit be1b1c8

Please sign in to comment.