SELECT * FROM EMPLOYEE WHERE AGE>40 AND (LOCATION='Chennai' OR NOT LOCATION='Agra');
How to write something similar to the above query statement in ObjectionJS/Knex ORM ?
SELECT * FROM EMPLOYEE WHERE AGE>40 AND (LOCATION='Chennai' OR NOT LOCATION='Agra');
How to write something similar to the above query statement in ObjectionJS/Knex ORM ?
Is this you looking for?
SELECT * FROM EMPLOYEE WHERE AGE>40 AND (LOCATION='Chennai' OR LOCATION <> 'Agra');
Assuming that you have model Employee
then you can use Objection.js query
Employee.query()
.select('*')
.where('age', '>', 40)
.where(builder => builder.where('location', 'Chennai')
.orWhereNot('location', 'Agra')
)
you can read more about Objection.js subqueries syntax here https://vincit.github.io/objection.js/recipes/subqueries.html