How to remove left join in function Knex.JS?

How to remove left join integration? await knex.select().from("dishes") .leftJoin("companies", function () { if (companyId) { this.on("dishes.companyId", "=", "companies.id") } else { // I want to remove left join if companyId is false return false; } }) I’m got an error: code: ‘ER_PARSE_ERROR’, sql: ‘select * from `dishes` left join `companies`’ } >Solution : It’s unclear… Read More How to remove left join in function Knex.JS?

knex Sort by JSON field values

I am using knex with mysql and have a table with json values like this: -Table 1 id | name | data ——+———-+————— 1 | Test | {"city_id": 3, "email":"test@test.com", "city_name":"something"} 2 | Test 2 | {"city_id": 1, "email":"test2@test2.com", "city_name":"another"} 3 | Test 3 | {"city_id": 6, "email":"test3@test3.com", "city_name":"blahblah"} how can i sort this table… Read More knex Sort by JSON field values

My database gets an object returned instead of a value

I am doing a post request on my database for user registers & every time the email gets returned as an object with this {"email":"karl@gmail.com"} instead of this karl@gmail.com This is the nodejs app.post("/register", (req, res) => { const { email, name, password } = req.body; var salt = bcrypt.genSaltSync(10); var hash = bcrypt.hashSync(password, salt);… Read More My database gets an object returned instead of a value