@go-mailer/jarvis 5.0.3 → 5.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/query.js +5 -2
  2. package/package.json +1 -1
package/lib/query.js CHANGED
@@ -178,8 +178,9 @@ const generatePipeline = ({ group_by, seek_conditions, sort_condition, sum, fiel
178
178
  $match: { ...seek_conditions }
179
179
  })
180
180
 
181
- if (sort_condition) {
182
- const sort_options = sort_condition.split(' ').reduce((sac, condition) => {
181
+ let sort_options = sort_condition
182
+ if (sort_condition && typeof(sort_condition) === 'string') {
183
+ sort_options = sort_condition.split(' ').reduce((sac, condition) => {
183
184
  let key = condition
184
185
  let value = 1
185
186
  if (key.includes('-')) {
@@ -189,7 +190,9 @@ const generatePipeline = ({ group_by, seek_conditions, sort_condition, sum, fiel
189
190
 
190
191
  return { ...sac, [key]: value }
191
192
  }, {})
193
+ }
192
194
 
195
+ if (sort_options && Object.keys(sort_options).length) {
193
196
  pipeline.push({
194
197
  $sort: { ...sort_options }
195
198
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-mailer/jarvis",
3
- "version": "5.0.3",
3
+ "version": "5.0.4",
4
4
  "main": "index.js",
5
5
  "repository": "git@github.com:go-mailer-ltd/jarvis-node.git",
6
6
  "author": "Nathan Oguntuberu <nateoguns.work@gmail.com>",