-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusersHelper.js
More file actions
43 lines (41 loc) · 1.06 KB
/
Copy pathusersHelper.js
File metadata and controls
43 lines (41 loc) · 1.06 KB
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
const ENV = process.env.ENV || "development";
const knexConfig = require("./knexfile");
const knex = require("knex")(knexConfig[ENV]);
const morgan = require('morgan');
const knexLogger = require('knex-logger');
module.exports = {
findUser: function(username) {
return knex
.select('*')
.from('users')
.where({'name': username})
.then(function(user){
return user;
})
.catch(function (e) {
console.error(e);
})
},
findUserWithPassword: function(username, password) {
return knex
.select('*')
.from('users')
.where({'name': username, 'password': password})
.then(function(user){
return user;
})
.catch(function (e) {
console.error(e);
})
},
addUser: function(username, password) {
return knex.insert([{'name': username,
'email': username + '@gmail.com',
'password': password}], 'id').into('users')
.then(function (){
})
.catch(function (e) {
console.error(e);
})
}
};