I have been developing an express application (server-side) that offers movie information to users, and I am attempting to send a JSON response in the following format: { "title": "Star Trek: First Contact", "year": 1996, ...
During my work on a project with KnexJS, I have been utilizing the .raw() method successfully. However, I recently encountered an issue where this method was not being properly integrated into the SQL query, resulting in a syntax error at end of input. 'u ...
I've defined my model like this: const User = db.Model.extend({ tableName: 'users', hasSecurePassword: true }); module.exports = User; With this setup, I can perform actions such as const User = require("../models/user"); ...
There is a function that reduces the stock in a database, but Knex is showing a 'Deadlock Detected' error when attempting to subtract quantities of 2 different items. This code contains loops to manage this issue. const updateOrder = (req, res, ...
I'm struggling to assign the result of a select query using Knexjs to a variable. Here is my code: function getAllCategories() { let categories; categories = database.from("categories").select("category").then(function (rows) { for (let row of ro ...
I'm facing a dilemma when it comes to using the Bookshelf model to insert data into the database in this particular scenario: The libraries I am working with include knex, bookshelf, express, body-parser, and a MySQL database In my database, there i ...
My node.js backend utilizes Knex.js to construct dynamic DB queries based on various inputs. The challenge I'm facing is handling asynchronous processing of certain inputs. When returning a knex query object from an async function or a Promise resolve ...
It seems like I'm facing a simple issue, but I can't quite figure out what mistake I'm making here. I have a table that displays all the different states: static get jsonSchema() { return { type: 'object', properties: { id: { type ...
I encountered an issue while using bookshelf js to create a query. When implementing orWhere in the query, I received an error message. An error occurred stating 'Object has no method 'orWhere'." Below is the code snippet that led to thi ...
I am trying to create a dynamic query that will include a where clause based on whether the variables name and/or city are passed. While I couldn't find a specific method for this in the documentation, I attempted to add the where clauses directly to the ...
Here is an example of the array I am working with: settings: [ { key: 'maxImageSize', value: '512' }, { key: 'maxFileSize', value: '2048' }, { key: 'searchResultsLimit', value: '10' ...
I am attempting to run the following query using knex.js and MySql SELECT m.id, TIME(date_created) AS `timestamp`, u.username, m.`message` FROM `messages` AS m INNER JOIN users AS u ON u.id = m.user_id WHERE m.game_id IS NULL AND m ...
Whenever I retrieve more than 10 thousand rows of raw data from the Database in a single GET request, the response takes a significant amount of time to reach the client side. Is there a method to send this data in smaller chunks to the client side? When ...
Attempting to execute a stored procedure located in the public schema with: const schema = await knex.raw("call create_schema(?, 'col1', 'col2', 'col3', 'col4', 'col5', 'col6')", schema_name); The purpose of this procedure is to establis ...
I am facing an issue with the login functionality of my application. While the register function works fine, I encounter a "501-not implemented" error when trying to log in. Here's a snippet from my code: const passport = require('passport') router.post( ...
Essentially, I am trying to figure out how to construct this query using Knex: SELECT * FROM usr_info WHERE login = ? AND password = PASSWORD(?) For instance: knex('usr_info') .where({ 'login': login, 'password': password // <-- include a ...
Currently, I have two tables in my database named 'temp_users' and 'ratings' TABLE 1 (temp_users) temp_user_id(primary key) | ip_address | total_ratings ----------------------------------------- | ...
I've been making progress with my understanding of Promises, but I'm puzzled by the behavior of knex in Node.js. When I successfully receive a query and log it out, everything seems fine. However, when I run node filename.js The process doesn't quit an ...
We currently have 30 DigitalOcean droplets, each dedicated to a web CRM user. They all share the same MySQL database using knex.js. However, with a few additional users, we are encountering some errors: "ER_CON_COUNT_ERROR: Too many connections" ...
As someone new to working with MySQL, I have previously used PSQL in a similar manner. However, the following code is generating an error. return await db .raw( `INSERT INTO users(firstName, lastName, email, ...
I recently started working on my first Node.js/Express.js API with a PostgreSQL database. After setting up the database and creating some tables last night, I encountered an issue today where I couldn't connect it to my backend. When trying to access it in ...
How to store JSON data in multiple tables and extract specific table data using knex and express.js The task at hand involves inserting data into three separate tables - login, user, and profile. Following this insertion, we need to retrieve the user and ...
Issues with connecting to a mysql database hosted in Azure using an express.js app and KNEX have been troublesome. While I can successfully connect to the database from the console command or mysql workbench, my node app fails to do so. The connection ob ...
I'm currently developing a search function based on tags, within a table structure like this CREATE TABLE permission ( id serial primary key, tags varchar(255)[], ); After adding a row with the tags "artist" and "default," I aim ...
I am trying to figure out how to make this function work. I only receive a promise as the output. codeProducts.forEach((code, index) => { const qt = app.db('products').where('code', code).first().then(result => result.quantity) data[ind ...
At the moment, I'm utilizing Knex to carry out queries on a MSSQL database. In my schema, there is a table named "Meals" which has the following columns: Id Additionally, there is also a table named "Vegetables" with the following columns: Id Meal (whi ...
Three tables are in my database: User, UserDrink, and VenueDrink Here is a preview of the sample data: User id | name | gender | -------------------- 1 | John | male | 2 | Jane | female | UserDrink id | count | user_id | venue_drink_id 1 | 3 | ...
I need assistance implementing the following SQL code in knex.js: select c.id,c.parent_id,c.comment,u.username,c.postid from comments as c join post_details as p on (p.id = c.postid and c.postid=15)join users as u on (u.id = c.userid); I attempt ...
How can I effectively utilize the knex db object across multiple files? As an illustration In my main index.js file: const app = require("express")(); const cors = require("cors"); const bodyParser = require("body-parser"); const user = require("./route ...
I am currently utilizing Proximo on Heroku to run my Node.js application in order to obtain a static IP address for outbound traffic. However, since implementing this setup, I have encountered an issue where the MySQL connection is timing out and refusing ...
Encountering a very peculiar issue during updates where I don't receive any response - no errors, warnings, success messages - it's as if nothing is changing. The request seems to be stuck in an infinite loop, always loading. I am using knex.js f ...
I've developed an API endpoint to manage user account creation within my Next.js application, utilizing knex.js for handling queries. Despite this, I keep encountering the following error: API resolved without sending a response for /api/users/create ...
Need help stubbing a chained knex query with Sinon. Here is the query: const result = await TableModel .query() .whereIn('id', idList) .whereIn('value', valueList); Usually, I use a custom helper function that stubs each method ...