diegohaz / diegohaz/querymen

Optional sort param

Open
#46 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
134
Forks
34
PR merge metrics
No merged PRs in 30d

Description

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!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.