Keystone-classic: 0.4: defaultSort does not seem to work

Created on 29 Dec 2015  ·  8Comments  ·  Source: keystonejs/keystone-classic

Not sure if it's just my environment (latest chrome, windows 10) but adding defaultSort: "name" to a list does not seem to enable sorting on that list field.

I've added keystonejs/keystonejs-site#54 just in case it's a documentation issue.

Warning messages in console:
image

Used like this (according to doc example):

var MyList = new keystone.List('MyList', {
    defaultSort: '+name'
});
MyList.add({
    name: {
        type: String,
    },
    ...
});
bug

Most helpful comment

Well, defaultSort : 'name' works, as does defaultSort : '-name'. Usage with a plus sign is not mentioned in the docs as far as I can tell, but probably should be possible for the sake of completeness.

All 8 comments

Can someone verify that default sort works (or not)? Perhaps I'm using it wrong? Perhaps the documentation needs more clarification?

Well, defaultSort : 'name' works, as does defaultSort : '-name'. Usage with a plus sign is not mentioned in the docs as far as I can tell, but probably should be possible for the sake of completeness.

Sounds reasonable @geloescht, should take a look at this after #2566 is merged!

Oops, just opened a pull request #2616

Will be fixed as soon as #2566 lands!

It seems likedefaultSort: '-createdAt' don't work.
Keystone 0.4. console warns: Invalid Sort specified: createdAt

I copy it from http://keystonejs.com/docs/database/#lists-example. What can be wrong?
Oh, i looked into database and there is no such field createdAt. Is this ok?

This issue was about using a plus sign as a possible prefix for defaultSort.
You could help us by trying to revert your keystone module to an earlier revision and see if it works there (try one or two months ago). If it does, that sounds like a regression and you should definitely file another bug report.

ok, sorry, I forget to add createdAt field. example contains it, so there is no mistake. it's my fault.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

javierpelozo picture javierpelozo  ·  5Comments

calebmcelroy picture calebmcelroy  ·  3Comments

josephg picture josephg  ·  4Comments

koenoe picture koenoe  ·  4Comments

rigalpatel001 picture rigalpatel001  ·  5Comments