@@ -27,6 +27,8 @@ module.exports = (sequelize, Sequelize) => {
2727 constructor ( queryBuilder , column ) {
2828 this . queryBuilder = queryBuilder ;
2929 this . column = column ;
30+
31+ this . notFlag = false ;
3032 }
3133
3234 /**
@@ -40,7 +42,16 @@ module.exports = (sequelize, Sequelize) => {
4042 this . queryBuilder . options . where = { } ;
4143 }
4244
43- this . queryBuilder . options . where [ this . column ] = value ;
45+ if ( this . notFlag ) {
46+ this . queryBuilder . options . where [ this . column ] = {
47+ [ Op . ne ] : value ,
48+ } ;
49+ } else {
50+ this . queryBuilder . options . where [ this . column ] = {
51+ [ Op . eq ] : value ,
52+ } ;
53+ }
54+
4455 return this . queryBuilder ;
4556 }
4657
@@ -55,9 +66,15 @@ module.exports = (sequelize, Sequelize) => {
5566 this . queryBuilder . options . where = { } ;
5667 }
5768
58- this . queryBuilder . options . where [ this . column ] = {
59- [ Op . and ] : values ,
60- } ;
69+ if ( this . notFlag ) {
70+ this . queryBuilder . options . where [ this . column ] = {
71+ [ Op . notIn ] : values ,
72+ } ;
73+ } else {
74+ this . queryBuilder . options . where [ this . column ] = {
75+ [ Op . and ] : values ,
76+ } ;
77+ }
6178
6279 return this . queryBuilder ;
6380 }
@@ -73,9 +90,15 @@ module.exports = (sequelize, Sequelize) => {
7390 this . queryBuilder . options . where = { } ;
7491 }
7592
76- this . queryBuilder . options . where [ this . column ] = {
77- [ Op . in ] : values ,
78- } ;
93+ if ( this . notFlag ) {
94+ this . queryBuilder . options . where [ this . column ] = {
95+ [ Op . notIn ] : values ,
96+ } ;
97+ } else {
98+ this . queryBuilder . options . where [ this . column ] = {
99+ [ Op . in ] : values ,
100+ } ;
101+ }
79102
80103 return this . queryBuilder ;
81104 }
@@ -92,12 +115,28 @@ module.exports = (sequelize, Sequelize) => {
92115 this . queryBuilder . options . where = { } ;
93116 }
94117
95- this . queryBuilder . options . where [ this . column ] = {
96- [ Op . between ] : [ start , end ] ,
97- } ;
118+ if ( this . notFlag ) {
119+ this . queryBuilder . options . where [ this . column ] = {
120+ [ Op . notBetween ] : [ start , end ] ,
121+ } ;
122+ } else {
123+ this . queryBuilder . options . where [ this . column ] = {
124+ [ Op . between ] : [ start , end ] ,
125+ } ;
126+ }
98127
99128 return this . queryBuilder ;
100129 }
130+
131+ /**
132+ * Sets the **NOT** flag to `true` for the next filter condition.
133+ *
134+ * @returns {WhereQueryBuilder } The current WhereQueryBuilder instance.
135+ */
136+ not ( ) {
137+ this . notFlag = true ;
138+ return this ;
139+ }
101140 }
102141
103142 /**
0 commit comments