I am trying to fetch data from the database in this way: I want all the templates and those templates have an array of categories in it so the methode I am currently using currently I am doing this but the object doesn’t seem to alter. Answer You are not waiting for the promises to resolve. You should do: instead
Tag: knex.js
Knex join on column belonging to same same table
Using Knex.js, I am attempting to query a table of users. The only columns that are important for this scenario are internal_id (key), name, and supervisor_id. Every user (except one) has a supervisor and their record stored the ID of that supervisor. When viewing an individual user record in my app, I want to query the users table getting info
Relational database created/stored on client [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations. Closed 5 months ago. Improve this question I’m in the early stages of designing an Electron application that
Convert Raw SQL to Bookshelf/Knex
I’m trying to convert a simple raw SQL to use Bookshelf/Knex in JavaScript: Original SQL: select * from o where o.id = 1 or o.id = 2 and (o.is_a = true or o.is_b = true) and o.status = ‘good’; I’ve tried to rewrite it in multiple ways using .orWhere .andWhere but cannot get the same result that I get from
SQL query to retrieve entries if userId matches table1’s employee_id or table2’s contributor_id
I’m trying to retrieve all kpi_id, kpi_name, employee_id, contributor_id from table1 and table2 if the provided userId matches employee_id from table1 or contributor_id from table2. Sample table1: id kpi_name employee_id 1 kpi1 5 2 kpi2 6 3 kpi3 9 Sample table2: id kpi_id contributor_id 1 1 9 1 3 5 1 1 6 Now, if a given userId is 5
Combine two columns and perform a where operation on the result
I have two columns, one for ‘firstName’ and one for ‘lastName’. I’m trying to perform a where operation on the concatenation of those two columns to match for a full name. Here is what I’ve tried: This just returns a blank array. Example Data: firstName lastName Clayton Smith Barbara Clayman Sam Peterson when some_value = Clay, it should return ‘Clayton
Knex not properly escaping raw postgres queries
I am using Knex (with typescript) to try to query a postgres database. My database table products has a column name that I want to search through as the user types into a search box. For example, a …
(SQL) Pulling linked profiles from two tables using Knex
I currently have two tables with the following data: I currently have my query set up like this with Knex: I’m currently parsing the data into the following format: This works totally fine except for the cases where the parent has no children, as it won’t pull any data at all, including parent info. Is there any workaround in this
How to add if statement in knex.select()?
I have code like this const attr = req.query.attr knex.select(knex.raw(‘foo_name as name’)) what I want is somehow select that column if it meets condition of attr and if does not then do select …
How do I populate a foreign key field with data instead of just foreign key id on select query?
I have 2 tables with class and subjects. class(id,name,student_count) subjects(id,name,class_id) I want to populate class_id with name,student_count, and id on the select query. How do I do this using SQL or Knex? I tried using join, but I get only one field not all fields in a row. The expected result would be: By the way, answer in Knex or