Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
feat(rns): adds sort by domain name (#495)
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajpiar authored Jan 15, 2021
1 parent 3b59ffc commit 6a40f46
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/services/rns/hooks/domain-offer.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export default {
}
}
}
const { params: { sequelize: { include } } } = context
const { params: { sequelize } } = context
const { include } = sequelize
const domain = context.params.query?.domain

if (include && domain) {
Expand All @@ -75,6 +76,24 @@ export default {
}
}

const sort = context.params.query?.$sort

if (sort && sort.domain) {
const { domain, ...$sort } = sort
context.params.query = {
...context.params.query,
$sort
}

sequelize.order = [
[
{
model: Domain,
as: 'domain'
}, 'name', domain.name > 0 ? 'ASC' : 'DESC'
]
]
}
return context
},
discardQuery('domain')
Expand Down

0 comments on commit 6a40f46

Please sign in to comment.