Questions tagged [mysqljs]

62 questions
1
vote
1 answer

Electron ERROR Error: Cannot find module 'mysql' Require stack:

My Electron app uses a nodejs dependency (in my case it's mysqljs) and it works fine when running on development mode. However when I build it and launch as a native desktop app, it fails with: Electron ERROR Error: Cannot find module 'mysql'…
Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252
1
vote
2 answers

insertId returning 0 after posting with mysqljs and stored procedure

Using mysqljs to query mySQL database via a stored procedure for a webAPI endpoint in express.js. I am required to return the inserted object. for this, I tried to acess the insrtedId based on the documentation from mysqljs. but the insertedid…
Firealem Erko
  • 347
  • 1
  • 2
  • 12
1
vote
0 answers

mysqljs ER_PARSE_ERROR in valid request

I'm using mysqljs and I want to delete a row in a table with its id: class_id is the id (string). connection.query( `DELETE FROM classes WHERE id = ?`, [class_id], (err, result) => { if (err) throw(err); resolve(); …
Romain C
  • 11
  • 1
  • 3
1
vote
2 answers

How to return results of a query? Mysql nodejs

I am using mysql package from https://www.npmjs.com/package/mysql So basically I have this function in a file: module.exports.listGames = (id) => { let query = 'SELECT * FROM test'; if (id) { query += 'WHERE userid = ' +…
user9227001
1
vote
2 answers

Is there a way to create NestJS API without typeorm but plain expressJS/mysql methods?

I have been trying to create an API in nestJS using just plain expressJS and mysql without using typeorm. However, there's little to no information for this either in the documentation or other sources. What I have done so far: Created a global…
Sanju
  • 1,478
  • 2
  • 20
  • 41
1
vote
0 answers

Why I can get mysql.js in node CLI but not in command line

I installed mysql.js through npm in Windows 10, however I get mysql module in node.js CLI but not from the command line. I tried the sample code which is given at the official mysql.js website with my local configuration, and it produces a…
Terry KF
  • 19
  • 2
1
vote
2 answers

how to disable fetch API to send OPTIONS request with Content-Type header?

I have a problem with my API. When I use fetch from ReactJS to send un json to NodeJS server, The server crashes... fetch call : const jso = JSON.stringify({ username: this.state.username, password: this.state.password }) …
etiennnr
  • 305
  • 5
  • 12
1
vote
1 answer

Accessing SQL object with handlebars to render on screen

I'm building a bookstore app am using an SQL database with the mysqljs module i can fetch all books from database but i want to access one book and display its details. I fetch the book object by its id and i display it in the console book details…
Baraa Araki
  • 61
  • 1
  • 6
1
vote
1 answer

Access part of a javascript array (mysqljs)

I am pulling data from a database in javascript using mysqljs I can get the output: { "Success": true, "Result": [{ "buttonName": "90p" }, { "buttonName": "£1.90" }, { "buttonName": "£4.90" …
Steven Helliwell
  • 77
  • 1
  • 1
  • 5
1
vote
1 answer

Set object name?

In mysqljs, the return value from a connection query is printed as [ RowDataPacket { column: "value" } ] which is equivalent to [ { column: "value" } ]. How does the library give the { column: "value" } object a "name" RowDataPacket? I thought it…
Avery235
  • 4,756
  • 12
  • 49
  • 83
1
vote
2 answers

Using mysql types in typescript

I have a nodejs typescript project that requires the use of mysqljs (https://www.npmjs.com/package/mysql), I've imported the DefinitelyTyped package (https://www.npmjs.com/package/@types/mysql) and included them in my tsconfig file tsconfig.json { …
uint32
  • 21
  • 1
  • 5
0
votes
1 answer

TypeORM database is always empty after restart

I just started using typeorm and ran into a major issue. Neither conection.sychronize() nor repository.save(foo) actually save changes to the database file. More precisly what is happening is that during runtine i can synchronize my db, save and…
hemmoleg
  • 125
  • 1
  • 8
0
votes
1 answer

Node mysql select result can't be stored into variable

I'm working on a script that insert and reads information on a mysql database. I've done the first step which is create registers on the database and works but I'm having issues reading the data out from the database. I have a main.ts that call all…
jcobo1
  • 1,065
  • 1
  • 18
  • 34
0
votes
1 answer

How i get mysql result callback value out of function scope in NodeJs?

I would like to know how to pass the value from mysql query to a variable out of the function: mydb.js const mysql = require('mysql'); const con = mysql.createConnection({ host: process.env.HOST, user: process.env.USER, password:…
0
votes
0 answers

How do you properly use mysqljs queries?

I have the following code: app.get('/', async function (req, res) { const mysql = require("mysql"); // Connection to db const connection = mysql.createConnection({ host: 'localhost', user: 'root', password:…
ArchieV
  • 13
  • 1
  • 1