Refactor customers API
* Use lodash camelize * Modify enhanceOverrideFields (fp) * Fix for sql timestamp * Fetch all existing users at once in populateOverrideUsernames * Modify populateOverrideUsernames (fp) * Break format function into computeStatus, camelize
This commit is contained in:
parent
e907f8a70a
commit
c77bb53f8f
2 changed files with 65 additions and 34 deletions
10
lib/users.js
10
lib/users.js
|
|
@ -1,3 +1,6 @@
|
|||
const _ = require('lodash/fp')
|
||||
const pgp = require('pg-promise')()
|
||||
|
||||
const db = require('./db')
|
||||
|
||||
function get (token) {
|
||||
|
|
@ -5,4 +8,9 @@ function get (token) {
|
|||
return db.oneOrNone(sql, [token])
|
||||
}
|
||||
|
||||
module.exports = { get }
|
||||
function getByIds (tokens) {
|
||||
const sql = 'select * from user_tokens where token in ($1^)'
|
||||
const tokensClause = _.map(pgp.as.text, tokens).join(',')
|
||||
return db.any(sql, [tokensClause])
|
||||
}
|
||||
module.exports = { get, getByIds }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue