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

Optional sort param #46

Open
chemitaxis opened this issue Jul 6, 2017 · 0 comments
Open

Optional sort param #46

chemitaxis opened this issue Jul 6, 2017 · 0 comments

Comments

@chemitaxis
Copy link
Collaborator

Hi @diegohaz, I'm thinking about mandatory sort. We are working with MongoDb, and some querys we don't need an index for sorting, but the "sort" param is always "one" because we have a default value:

sort: {
        type: [String],
        default: '-createdAt',
        bindTo: 'cursor',
        parse: (value) => {
          let fields = _.isArray(value) ? value : [value]
          let sort = {}
          fields.forEach((field) => {
            if (field.charAt(0) === '-') {
              sort[field.slice(1)] = -1
            } else if (field.charAt(0) === '+') {
              sort[field.slice(1)] = 1
            } else {
              sort[field] = 1
            }
          })
          return {sort: sort}
        }
      }

Can you please give some "light" to try this sort param in the Schema as "optional". Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant