/I’ve already established a connection in knex with mysql and i am trying to do a loginForm connected to mysql db and right now i am doing a login check.I was wondering if there is any difference between this: knex().select("id").from("users)
and this: knex("users").select("id")/
function checkLogIn(email, username, password) {
knex("users").select("id").where({
email: "[email protected]",
username: "username",
password: "password",
})
}
2
Answers
In cases where you are undecided, you can print the pure sql statement to the console as in the example below:
No, There is no difference between using
knex().select("id").from("users)
orknex("users").select("id")
.knex().select("id").from("users)
=> This is simply method chaining where select and from methods are used. Query at execution time will beselect id from users
knex("users").select("id")
=> Here, knex knows that the tableName can be passed in param and at execution time will convert the query toselect id from users