This is my model.js
module.exports.getUser = userId => {
const sql = {
sql: "SELECT * from user where user_id=?"
};
const sqlParams = [userId];
connection.query(sql, sqlParams, (error, results, fields) => {
// Handle error after the release.
if (error) throw error;
console.log(results);
return results;
});
};
this is my service.js
module.exports.getUser = () => {
let user = User.getUser(1);
console.log(user);
return user;
};
But in my service.js file its coming as undefined but in model.js (inside the callback) its printing the results correctly.
how can i pass this results back to the calling method in service.js
hi there, i had a problem with my sql, it's simple but i can't figure out why it can excute sometimes but offten can't excute successfully.
DELETE FROM general_log where sqltext='SET NAMES utf8' LIMIT 240
the error is
[Err] 1206 - The total number of locks exceeds the lock table size
nflfeedjoblog
(BatchId
int(30) NOT NULL AUTO_INCREMENT,processDate
datetime DEFAULT NULL,status
smallint(6) DEFAULT '0',pmid
int(11) DEFAULT '0',NFLTransactionId
int(30) DEFAULT '0',BatchId
),NewIndex1
(BatchId
,NFLTransactionId
),NewIndex2
(processDate
)NewIndex1
(BatchId
,NFLTransactionId
)" tjhis does ?
Hi guys! Having made a simple query with count() operator i'm obtaining badly formatted response where the value's name in object is a part of my query that looks stupid
[ RowDataPacket { 'count(distinct `jpp`.`job_position_id`)': 10 } ]
could I somehow change it?
Thanks.
select * from project_application_records par inner join (select * from project_version pv where pv.project_id = par.project_id order by version desc limit 1) as prv