For ObjectionJS, as this line will fetch all the persons in db:
const people = await Person.query();
Would the query() in the line below fetch all the persons in db before executing the findById function?
const person = await Person.query().findById(1);
One thing I want to ensure is to fetch minimal data from database. Thanks.
CodePudding user response:
if you check the documentation the query in the .findById
case is built before sending to database, so any chaining you do with where
or anything else is set into the statement before executing:
SELECT * FROM persons;
first caseSELECT * FROM persons where id=1;
second case