Skip to content

Commit

Permalink
feat(query): contains
Browse files Browse the repository at this point in the history
  • Loading branch information
koriwi committed Sep 26, 2019
1 parent a2e9ede commit cf45f18
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/mapping/q.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class QueryAssignment {
* Contains functions that represents operators in a query.
* @alias module:mapping~q
* @type {Object}
* @property {function} contains Represents the CQL operator "CONTAINS".
* @property {function} containsKey Represents the CQL operator "CONTAINS KEY".
* @property {function} in_ Represents the CQL operator "IN".
* @property {function} gt Represents the CQL operator greater than ">".
* @property {function} gte Represents the CQL operator greater than or equals to ">=" .
Expand All @@ -91,6 +93,14 @@ class QueryAssignment {
* @property {function} remove Represents the CQL remove assignment used for collections, e.g: "col = col - x"
*/
const q = {
contains: function contains(value) {
return new QueryOperator('CONTAINS', value);
},

containsKey: function containsKey(value) {
return new QueryOperator('CONTAINS KEY', value);
},

in_: function in_(arr) {
if (!Array.isArray(arr)) {
throw new errors.ArgumentError('IN operator supports only Array values');
Expand Down Expand Up @@ -119,7 +129,7 @@ const q = {
},

and: function (condition1, condition2) {
return new QueryOperator('AND', [ condition1, condition2 ], true);
return new QueryOperator('AND', [condition1, condition2], true);
},

incr: function incr(value) {
Expand Down

0 comments on commit cf45f18

Please sign in to comment.