hash_ Posted June 8, 2021 Posted June 8, 2021 Hello I'm fairly new to RAGEMP development using JS So i have this function sql.js : module.exports = function SQLQuery(player,sql,returning = 0) { connection.query(sql, function (err,result) { if (err) { console.log('[SQL-ERROR] : ' + err); throw err; } else //do stuff if(returning != 0) return result; }); } //or exporting using this >> module.exports.SQLQuery = SQLQuery(); im trying to read the "results" I've returned from the SQLQuery function in my LoginReg.JS file which looks like this : const sql = require("./mysql.js")(); function SocialClubCheck(player,clubid) { var exists = sql.SQLQuery(player,`SELECT COUNT * FROM accounts WHERE rockstar_id = ${clubid}`,1); if(exists[0] != 0 ) console.log(`account with ${clubid} FOUND! `); else console.log(`account with ${clubid} NOT FOUND! `); } but i don't think I'm doing it the right way i keep getting this error : TypeError: Cannot read property 'SQLQuery' of undefined var exists = sql.SQLQuery(player,`SELECT COUNT * FROM accounts WHERE rockstar_id = ${clubid}`,1); i would like any kind of hints of what am i doing wrong here Thanks
leodok Posted June 29, 2021 Posted June 29, 2021 You're calling your exported function here const sql = require("./sql.js")(); Try const sql = require("./sql.js"); // then var exists = sql(player,etc etc
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now