-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmysql.js
50 lines (34 loc) · 889 Bytes
/
mysql.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* Created by sandeep on 13/07/17.
*/
var mysql = require('mysql');
var dbconfig = {
host : 'localhost',
user : 'expenso',
password : 'expenso',
database: 'expensouser'
};
function getDetails(email,cb) {
var connection = mysql.createConnection(dbconfig);
connection.connect();
connection.query('SELECT * FROM sign_up WHERE email="'+email+'"',function (error,results,fields) {
cb(results);
});
}
function signUp(data,cb) {
var connection = mysql.createConnection(dbconfig);
connection.connect();
var sign = {
name: data.name,
email: data.email,
password: data.password
}
connection.query('INSERT INTO sign_up SET ?', sign, function (err,result,fields) {
if(err) throw err;
cb(result);
});
}
module.exports = {
signUp : signUp,
getDetails : getDetails
}