Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query operator contains #337

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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