@go-mailer/jarvis 3.1.1 → 3.1.2

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 +19 -1
  2. package/package.json +1 -1
package/lib/query.js CHANGED
@@ -1,12 +1,13 @@
1
1
  const buildQuery = (options) => {
2
- const seek_conditions = {}
3
2
  const sort_condition = options.sort_by ? buildSortOrderString(options.sort_by) : ''
4
3
  const fields_to_return = options.return_only ? buildReturnFieldsString(options.return_only) : ''
5
4
  const count = options.count || false
5
+ const seek_conditions = { ...buildBooleanQuery(options.bool || '')}
6
6
 
7
7
  const { skip, limit } = determinePagination(options.page, options.population)
8
8
 
9
9
  /** Delete sort and return fields */
10
+ delete options.bool
10
11
  delete options.count
11
12
  delete options.page
12
13
  delete options.population
@@ -40,6 +41,23 @@ const buildQuery = (options) => {
40
41
  }
41
42
  }
42
43
 
44
+ const buildBooleanQuery = (value) => {
45
+ const values = value.split(',')
46
+ return values.reduce((sac, val) => {
47
+ let truthiness = true
48
+ let key = val
49
+ if (val[0] === '-') {
50
+ truthiness = false
51
+ key = val.substr(1)
52
+ }
53
+
54
+ return {
55
+ ...sac,
56
+ [key]: truthiness
57
+ }
58
+ }, {})
59
+ }
60
+
43
61
  const buildInQuery = (value) => {
44
62
  const values = value.split(':')
45
63
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-mailer/jarvis",
3
- "version": "3.1.1",
3
+ "version": "3.1.2",
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>",