Documentation as per SQL adapters below.
Where column equals value.
Where column doesn't equal to value.
Where column is less than value
Where column is less than or equal to value
Where column is greater than value
Where column is greater than or equal to value
Where column is LIKE value.
Example:
db.query()
.from('posts')
.where(function (expr) {
expr.like('title', '%hello%'); // where `title` contains the text `hello`
})
.run();
Where column is not LIKE value.
Where column is one of the given values.
Example:
db.query()
.from('users')
.where(function (expr) {
expr.in('id', [1, 2, 3]); // where `id` is either 1, 2, or 3.
});
Where column is not one of the given values
Where column is null
Where column is not null
Where column is between from and to.
Example:
db.query()
.from('posts')
.where(function (expr) {
expr.between('views_count', 1000, 2000); // where `views_count` is between 1000 and 2000
})
.run();
Where column is not between from and to.
Nests further conditions with AND
operator.
Example:
db.query()
.from('users')
.where(function (expr) {
expr
.eq('active', 1)
.and(function (expr) {
expr.eq('role_id', 2);
});
})
.run();
Nests further conditions with OR
operator.
Example:
db.query()
.from('users')
.where(function (expr) {
expr
.eq('active', 1)
.or(function (expr) {
expr.eq('super_admin', 1);
});
})
.run();
Nests further conditions with NOT
operator.
Example:
db.query()
.from('users')
.where(function (expr) {
expr
.eq('active', 1)
.not(function (expr) {
expr.eq('spammer', 1);
});
})
.run();