mongo-query-builder-chain
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -26,2 +26,4 @@ const mongoQBModule = require('./module'); | ||
.addToQuery(['field4'], mongoQBModule.MongoQuery.$lte(mongoQBModule.MongoQuery.$date(1593727200000)), true) | ||
.removeFromQuery(['field3']) | ||
.addToQuery(['field5'], 1) | ||
.addToQuery([], mongoQBModule.MongoQuery.$language(), true) | ||
@@ -39,1 +41,5 @@ .projectionAdd(['projection_field2', 'projection_field3', 'projection_field4']) | ||
.getValue(), false, null, true)); | ||
console.log(mongoQB.hasKey(['field2'])); | ||
console.log(mongoQB.hasKey(['field3'])); | ||
console.log(mongoQB.hasKey(['field1', '$ne'])); |
@@ -96,2 +96,17 @@ var helpers = require('./helpers'); | ||
hasKey(keyPath = []) { | ||
if (Array.isArray(keyPath)) { | ||
let value = this.body.query; | ||
keyPath.forEach(key => { | ||
if (!value) { | ||
return false; | ||
} | ||
value = value[key]; | ||
}); | ||
return !!value; | ||
} else { | ||
throw "Argument keyPath must be an array!"; | ||
} | ||
} | ||
getValue(keyPath = []) { | ||
@@ -98,0 +113,0 @@ if (Array.isArray(keyPath)) { |
@@ -20,3 +20,3 @@ { | ||
"type": "module", | ||
"version": "1.1.1" | ||
"version": "1.1.2" | ||
} |
@@ -39,2 +39,7 @@ # mongo-query-builder-chain | ||
Checks whether the key _field11_ under _field1_ exists in the query. It returns true or false. | ||
```javascript | ||
mongoQuery.hasKey(['field1', 'field11']); | ||
``` | ||
Create a clause with a key _clause_field_ with a value _clause_value_ | ||
@@ -41,0 +46,0 @@ ```javascript |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24136
11
506
190