Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting associated items #196

Closed
devpascoe opened this issue Jun 11, 2013 · 2 comments
Closed

Sorting associated items #196

devpascoe opened this issue Jun 11, 2013 · 2 comments

Comments

@devpascoe
Copy link
Collaborator

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 :)

@dresende
Copy link
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).

@dresende
Copy link
Owner

dresende commented Jul 2, 2013

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
Projects
None yet
Development

No branches or pull requests

2 participants