You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
const pg = require('../pg')
|
|
|
|
const joinjs = require('join-js').default;
|
|
|
|
const debug = require('debug')('sos:db:user')
|
|
|
|
const mappings = require('../mappings')
|
|
|
|
|
|
|
|
const bcrypt = require('bcrypt')
|
|
|
|
|
|
|
|
const user = module.exports = {}
|
|
|
|
|
|
|
|
user.findById = async (user_uuid) => {
|
|
|
|
const query = {
|
|
|
|
text: 'select * from "user" where user_uuid = $1',
|
|
|
|
values: [
|
|
|
|
user_uuid
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
debug(query);
|
|
|
|
|
|
|
|
const result = await pg.query(query)
|
|
|
|
return joinjs.map(result.rows, mappings, 'userMap', 'user_')[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
user.register = async (email, password) => {
|
|
|
|
const hash = await bcrypt.hash(password, process.env.PW_SALTROUNDS || 10)
|
|
|
|
|
|
|
|
const query = {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|