showing results for - "sequelize and"
Isabel
05 Feb 2019
1const { Op } = require("sequelize");
2Post.findAll({
3  where: {
4    [Op.and]: [{ a: 5 }, { b: 6 }],            // (a = 5) AND (b = 6)
5    [Op.or]: [{ a: 5 }, { b: 6 }],             // (a = 5) OR (b = 6)
6    someAttribute: {
7      // Basics
8      [Op.eq]: 3,                              // = 3
9      [Op.ne]: 20,                             // != 20
10      [Op.is]: null,                           // IS NULL
11      [Op.not]: true,                          // IS NOT TRUE
12      [Op.or]: [5, 6],                         // (someAttribute = 5) OR (someAttribute = 6)
13
14      // Using dialect specific column identifiers (PG in the following example):
15      [Op.col]: 'user.organization_id',        // = "user"."organization_id"
16
17      // Number comparisons
18      [Op.gt]: 6,                              // > 6
19      [Op.gte]: 6,                             // >= 6
20      [Op.lt]: 10,                             // < 10
21      [Op.lte]: 10,                            // <= 10
22      [Op.between]: [6, 10],                   // BETWEEN 6 AND 10
23      [Op.notBetween]: [11, 15],               // NOT BETWEEN 11 AND 15
24
25      // Other operators
26
27      [Op.all]: sequelize.literal('SELECT 1'), // > ALL (SELECT 1)
28
29      [Op.in]: [1, 2],                         // IN [1, 2]
30      [Op.notIn]: [1, 2],                      // NOT IN [1, 2]
31
32      [Op.like]: '%hat',                       // LIKE '%hat'
33      [Op.notLike]: '%hat',                    // NOT LIKE '%hat'
34      [Op.startsWith]: 'hat',                  // LIKE 'hat%'
35      [Op.endsWith]: 'hat',                    // LIKE '%hat'
36      [Op.substring]: 'hat',                   // LIKE '%hat%'
37      [Op.iLike]: '%hat',                      // ILIKE '%hat' (case insensitive) (PG only)
38      [Op.notILike]: '%hat',                   // NOT ILIKE '%hat'  (PG only)
39      [Op.regexp]: '^[h|a|t]',                 // REGEXP/~ '^[h|a|t]' (MySQL/PG only)
40      [Op.notRegexp]: '^[h|a|t]',              // NOT REGEXP/!~ '^[h|a|t]' (MySQL/PG only)
41      [Op.iRegexp]: '^[h|a|t]',                // ~* '^[h|a|t]' (PG only)
42      [Op.notIRegexp]: '^[h|a|t]',             // !~* '^[h|a|t]' (PG only)
43
44      [Op.any]: [2, 3],                        // ANY ARRAY[2, 3]::INTEGER (PG only)
45
46      // In Postgres, Op.like/Op.iLike/Op.notLike can be combined to Op.any:
47      [Op.like]: { [Op.any]: ['cat', 'hat'] }  // LIKE ANY ARRAY['cat', 'hat']
48
49      // There are more postgres-only range operators, see below
50    }
51  }
52});
53
Nicole
16 May 2016
1{ where: { [Op.and]: [{ Col1: val1 }, { Col2: val2 }]} }
queries leading to this page
sequelize with clauseand in where clause sequelizeo que c3 a9 sequelize 3fsequelize org where insequelize for orm 28sequelize 2c sequelize 29sequelize salwhere or sequelizesequelize where 21 3dsequelize orm node jssequelize sql withsequelize ormsequelize or querysequelizeoperators sequelizesequelize in clausesequelize where 3e 3dsequelize operators examplewhere 22sequelize 22 in operatorsequelize and operatorsequelize include where orsequelize andd between orsequelize data typessequelize where can i add an 26 26 3fsequelize query orand operator sequelizesequelize or operatorsequelize operationsequelize where orsequelize 22 clausewhere and and statements sequelizesequelize op and examplesequelize org and operationsequelize where and or sequelize and orsequelize with queryusing or in sequelize querieswhere or in sequelizesequelize operators orsequelize 3 and or wherehow to use where in sequelize sequelize where opsequelize op or examplequery for sequelizesequelize query withsequelize operatorswhere in sequelizeor clause sequelizewhere is sequelizewhere and and in sequelizesequelize where 24sequelize thiswhere with and in sequelizesequelize where examplewhat sequelize ormsequelize define 28 29sequelize orm where or include sequelizeor operator sequelizesequelize where can i add an andwhere sequelize sequelize in querysequelize nodejssequelize sqlsequelize highlightsequelize wheresequelize o que c3 a9sequelize in operatorwhere in in sequelizesequelize where op or op andop and where sequelizesequelize using thisand query sequelize using sequelizesequelize and wheresequelize where with andsequelize where inwhere on in sequelizesequelize in sqlsequelize or ormsequelize syntaxsequelize where and andsequelize operators insequelize and clausesequelize or wheresequelize query or andsequelize where in 2a sequelize where or includesequelize where or mysqlsequelize or in wheresequelize functionor and in sequelize wheresequelize then wheresequelize operations operatorsusing or in sequelizesequelize where in querysequelize where and wheremodel sequelizesequalize querysequelize where with orsequelize andsequelize where andsequelize definitionwhere with in in sequelizesequelize where functionsequelize org or wheresequelize function in wheresequelize where or examplesequelize where or wheresequelize where in 28 29sequelize in examplesequelize orm in conditionsequelize nodejs 24orsequelize and