How to use the where function from sequelize

Find comprehensive JavaScript sequelize.where code examples handpicked from public code repositorys.

57
58
59
60
61
62
63
64
65
66
    include: [
        {model: Review},
        {model: SpotImage}
    ],
    where: {
        name: sequelize.where(sequelize.fn('LOWER', sequelize.col('name')), 'LIKE', '%' + searchValue + '%')
    }
})
console.log('inside of searching route====================', searchSpots)
let searchSpotsResults = [];
fork icon0
star icon2
watch icon1

20
21
22
23
24
25
26
27
28
29
? {
    ...where,
    [group.kind === 'OR' ? Op.or : Op.and]: group.items.reduce(
      (prev, f) => [
        ...prev,
        sequelize.where(sequelize.col(f.name), {
          [comparerType[f.comparer || 'Equals']]: f.value,
        }),
      ],
      [],
fork icon0
star icon0
watch icon1

+ 2 other calls in file

87
88
89
90
91
92
93
94
95
const itemsReduce = items.map(f =>
  customFields[f.name] !== undefined
    ? sequelize.where(customFields[f.name][0], {
        [comparerType[f.comparer || 'Equals']]: f.value,
      })
    : sequelize.where(sequelize.col(f.name), {
        [comparerType[f.comparer || 'Equals']]: f.value,
      }),
)
fork icon0
star icon0
watch icon1

+ 5 other calls in file

10
11
12
13
14
15
16
17
18
19
if(req.query.search && req.query.search !== null && req.query.search !== undefined && req.query.search !== ''){
    search.push({'$id$': Sequelize.where(
        Sequelize.fn('LOWER', Sequelize.col('id')), 'LIKE',
        `%${req.query.search.toLowerCase()}%`
    )})
    search.push({'$title$': Sequelize.where(
        Sequelize.fn('LOWER', Sequelize.col('title')), 'LIKE',
        `%${req.query.search.toLowerCase()}%`
    )})
    search.push({'$code$': Sequelize.where(
fork icon0
star icon0
watch icon1

+ 2 other calls in file

41
42
43
44
45
46
47
48
49
50
if(req.query.search && req.query.search !== null && req.query.search !== undefined && req.query.search !== ''){
    search.push({'$id$': Sequelize.where(
        Sequelize.fn('LOWER', Sequelize.col('id')), 'LIKE',
        `%${req.query.search.toLowerCase()}%`
    )})
    search.push({'$username$': Sequelize.where(
        Sequelize.fn('LOWER', Sequelize.col('username')), 'LIKE',
        `%${req.query.search.toLowerCase()}%`
    )})
    search.push({'$name$': Sequelize.where(
fork icon0
star icon0
watch icon1

+ 2 other calls in file

303
304
305
306
307
308
309
310
311
312
 */
async playerNameToXBoxId(playerName) {
  const name = playerName.toLowerCase();
  const player = await this.Player.findOne({
    where: { [Op.or]: [
      sequelize.where(sequelize.fn('lower', sequelize.col('gamertag')), name),
      sequelize.where(sequelize.fn('lower', sequelize.col('nickname')), name),
    ] },
  });
  return player?.xboxId;
fork icon0
star icon0
watch icon2

+ 39 other calls in file

40
41
42
43
44
45
46
47
48
49
exports.search = async (req, res) => {
  try {
    const users = await User.findAll({
      where: {
        [sequelize.Op.or]: {
          namesConcated: sequelize.where(
            sequelize.fn(
              "concat",
              sequelize.col("firstName"),
              " ",
fork icon0
star icon0
watch icon1

+ 4 other calls in file

75
76
77
78
79
80
81
82
83
84
  cert_banner: path2,
  created_by: req.body.mt_user_id,
  status: 1,
};
 Halal_cert.findAll({
    where: Sequelize.where(
      Sequelize.fn('lower', Sequelize.col('cert_name')), 
      Sequelize.fn('lower', req.body.cert_name)
    )
  })
fork icon0
star icon0
watch icon1

+ 3 other calls in file

146
147
148
149
150
151
152
153
154
155
  status: 1,
};
const newName = req.body.br_product_name.trim();
Brand_product.findAll({
  where: Sequelize.and(
    Sequelize.where(
      Sequelize.fn("lower", Sequelize.col("br_product_name")),
      Sequelize.fn("lower", newName)
    ),
    { status: 1 }
fork icon0
star icon0
watch icon1

+ 3 other calls in file

12
13
14
15
16
17
18
19
20
21
if(req.query.search && req.query.search !== null && req.query.search !== undefined && req.query.search !== ''){
    search.push({'$id$': Sequelize.where(
        Sequelize.fn('LOWER', Sequelize.col('data_master.id')), 'LIKE',
        `%${req.query.search.toLowerCase()}%`
    )})
    search.push({'$description$': Sequelize.where(
        Sequelize.fn('LOWER', Sequelize.col('description')), 'LIKE',
        `%${req.query.search.toLowerCase()}%`
    )})
}
fork icon0
star icon0
watch icon1

+ 3 other calls in file

16
17
18
19
20
21
22
23
24
25
    )})
    search.push({'$description$': Sequelize.where(
        Sequelize.fn('LOWER', Sequelize.col('description')), 'LIKE',
        `%${req.query.search.toLowerCase()}%`
    )})
    search.push({'$program_description$': Sequelize.where(
        Sequelize.fn('LOWER', Sequelize.col('program_description')), 'LIKE',
        `%${req.query.search.toLowerCase()}%`
    )})
}
fork icon0
star icon0
watch icon1

+ 2 other calls in file

52
53
54
55
56
57
58
59
60
61
  pro_name: req.body.pro_name,
  pro_image:path,
  status:"1",
};
Products.findAll({
  where: sequelize.where(
    sequelize.fn('lower', sequelize.col('pro_name')), 
    sequelize.fn('lower', req.body.pro_name)
  )
})
fork icon0
star icon0
watch icon1

+ 3 other calls in file