mirror of
https://github.com/harish2704/knex-json-query.git
synced 2026-09-10 04:41:07 +00:00
Add 'where not in' statement
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
var functionOperatorMap = {
|
||||
BETWEEN: 'whereBetween',
|
||||
IN: 'whereIn',
|
||||
NIN: 'whereNotIn',
|
||||
NOTIN: 'whereNotIn',
|
||||
ISNULL: 'whereNull',
|
||||
NOTNULL: 'whereNotNull',
|
||||
/* ---- */
|
||||
@@ -14,11 +16,13 @@ var functionOperatorMap = {
|
||||
/* ---- */
|
||||
OR_BETWEEN: 'orWhereBetween',
|
||||
OR_IN: 'orWhereIn',
|
||||
OR_NOTIN: 'orWhereNotIn',
|
||||
OR_ISNULL: 'orWhereNull',
|
||||
IR_NOTNULL: 'orWhereNotNull',
|
||||
/* ---- */
|
||||
AND_BETWEEN: 'andWhereBetween',
|
||||
AND_IN: 'andWhereIn',
|
||||
AND_NOTIN: 'andWhereNotIn',
|
||||
AND_ISNULL: 'andWhereNull',
|
||||
AND_NOTNULL: 'andWhereNotNull',
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ require('simple-mocha');
|
||||
|
||||
|
||||
var conditions= [
|
||||
/* -----------Tests for and conditoins---------- */
|
||||
/* -----------Tests for and conditions---------- */
|
||||
{
|
||||
name: 'handle simple and conditions',
|
||||
input:{ f1: 10, f2: 20, f3: 30 },
|
||||
@@ -42,6 +42,11 @@ var conditions= [
|
||||
input:{ f1: ['IN', [10,50]], f2: [ '<', 20 ], f3: 30 },
|
||||
output: 'select * where ("f1" in (10, 50) and "f2" < 20 and "f3" = 30)'
|
||||
},
|
||||
{
|
||||
name: 'handle basic operators :: notin',
|
||||
input:{ f1: ['NOTIN', [10,50]], f2: [ '<', 20 ], f3: 30 },
|
||||
output: 'select * where ("f1" not in (10, 50) and "f2" < 20 and "f3" = 30)'
|
||||
},
|
||||
{
|
||||
name: 'handle multiple conditions in one field',
|
||||
input:{ f1: [ [ 'LIKE', 20 ], 21, [ 'AND_BETWEEN', [ 40, 45 ] ] ], f2: 20, f3: 30 },
|
||||
@@ -62,7 +67,12 @@ var conditions= [
|
||||
input:{ f1: ['IN', [ 50, 60 ] ], f2: 20, f3: 30 },
|
||||
output: 'select * where ("f1" in (50, 60) and "f2" = 20 and "f3" = 30)'
|
||||
},
|
||||
/* -----------Tests for or conditoins---------- */
|
||||
{
|
||||
name: 'handle simple and condition with not in statement',
|
||||
input:{ f1: ['NOTIN', [ 50, 60 ] ], f2: 20, f3: 30 },
|
||||
output: 'select * where ("f1" not in (50, 60) and "f2" = 20 and "f3" = 30)'
|
||||
},
|
||||
/* -----------Tests for or conditions---------- */
|
||||
{
|
||||
name: 'handle simple or condition',
|
||||
input:[ { f1: 10 }, { f2: 20 }, { f3: 30 } ],
|
||||
@@ -103,11 +113,21 @@ var conditions= [
|
||||
input:[ { f1: ['IN',[ 50, 60 ]] }, { f2: 20 }, { f3: 30 } ],
|
||||
output: 'select * where (("f1" in (50, 60)) or ("f2" = 20) or ("f3" = 30))'
|
||||
},
|
||||
{
|
||||
name: 'handle simple or condition with not in statement',
|
||||
input:[ { f1: ['NOTIN',[ 50, 60 ]] }, { f2: 20 }, { f3: 30 } ],
|
||||
output: 'select * where (("f1" not in (50, 60)) or ("f2" = 20) or ("f3" = 30))'
|
||||
},
|
||||
{
|
||||
name: 'handle simple or condition with in statement :MongoQuery',
|
||||
input:[ { f1: {$in:[ 50, 60 ]} }, { f2: 20 }, { f3: 30 } ],
|
||||
output: 'select * where (("f1" in (50, 60)) or ("f2" = 20) or ("f3" = 30))'
|
||||
},
|
||||
{
|
||||
name: 'handle simple or condition with nin statement :MongoQuery',
|
||||
input:[ { f1: {$nin:[ 50, 60 ]} }, { f2: 20 }, { f3: 30 } ],
|
||||
output: 'select * where (("f1" not in (50, 60)) or ("f2" = 20) or ("f3" = 30))'
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user