Skip to content

Sorting associated items #196

Closed
Closed

Description

@devpascoe

Do we have it? if so whats the syntax.

Additionally, i am creating my model's associations with column in the lookup table
eg.

db.Product.hasMany("additionalmedia", db.MediaItem, { order: Number }, {
    reverse : "additionalproducts"
});

I'd like to be able to sort by order.
Both

product.getAdditionalmedia('order', function (err, additionalImages) {

and

product.getAdditionalmedia({}, 'order', function (err, additionalImages) {

don't seem to have any effect.

Thanks :)

Activity

  1. dresende commented on Jun 11, 2013

    @dresende
    Owner

    Try:

    product.getAdditionalmedia([ 'order' ], function (err, additionalImages) {

    I have to change it to support a string so you can just pur order (asc) or -order (desc).

  2. dresende commented on Jul 2, 2013

    @dresende
    Owner

    You can use "order" (ascending) or "-order" (descending).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions