2

I'm trying to order by on a belongsToMany relationship. I would like to order by the column firstName of the Subscriptions table, which is returned with the event.getSubscriptions() query. Here's where I'm at right now:

return event.getSubscriptions({
  where: {
    id: {
      $ne: event.currentUserId
    }
  },
  order: // I would like to order by the Subscription.firstName column
})

How can I go about doing this?

Thanks in advance!

Thomas
  • 2,356
  • 7
  • 23
  • 59

1 Answers1

3

You can do like this

return event.getSubscriptions({
  where: {
    id: {
      $ne: event.currentUserId
    }
  },
      order: 'firstName'
})

for descending just change order : 'firstName DESC'

Keval
  • 3,246
  • 20
  • 28