Sort labels by position order

This commit is contained in:
Hongbo Wu 2022-07-28 10:46:05 +08:00
parent 5e8508e025
commit 31d8f72840
3 changed files with 5 additions and 2 deletions

View file

@ -28,4 +28,7 @@ export class Label {
@CreateDateColumn()
createdAt!: Date
@Column('integer', { default: 0 })
position!: number
}

View file

@ -57,7 +57,7 @@ export const labelsResolver = authorized<LabelsSuccess, LabelsError>(
relations: ['labels'],
order: {
labels: {
createdAt: 'DESC',
position: 'ASC',
},
},
})

View file

@ -101,7 +101,7 @@ describe('Labels API', () => {
user: { id: user.id },
})
expect(res.body.data.labels.labels).to.eql(
labels.reverse().map((label) => ({
labels.map((label) => ({
id: label.id,
name: label.name,
color: label.color,