Feat: abstract extended queries; strip out default funcs from db obj
This commit is contained in:
parent
471782cbd7
commit
081957c957
4 changed files with 694 additions and 632 deletions
|
|
@ -29,6 +29,9 @@ const pgp = Pgp({
|
|||
obj.$one = (query, variables) => extendedQueries.one(obj, query, variables)
|
||||
obj.$none = (query, variables) => extendedQueries.none(obj, query, variables)
|
||||
obj.$any = (query, variables) => extendedQueries.any(obj, query, variables)
|
||||
// when opts is not defined "cb" occupies the "opts" spot of the arguments
|
||||
obj.$tx = (opts, cb) => typeof opts === 'function' ? extendedQueries.tx(obj, {}, opts) : extendedQueries.tx(obj, opts, cb)
|
||||
obj.$task = (opts, cb) => typeof opts === 'function' ? extendedQueries.task(obj, {}, opts) : extendedQueries.task(obj, opts, cb)
|
||||
},
|
||||
error: (err, e) => {
|
||||
if (e.cn) logger.error('Database not reachable.')
|
||||
|
|
@ -40,13 +43,13 @@ const pgp = Pgp({
|
|||
}
|
||||
})
|
||||
|
||||
const db = pgp(psqlUrl)
|
||||
const db = extendedQueries.stripDefaultDbFuncs(pgp(psqlUrl))
|
||||
|
||||
eventBus.subscribe('log', args => {
|
||||
if (process.env.SKIP_SERVER_LOGS) return
|
||||
|
||||
const { level, message, meta } = args
|
||||
const msgToSave = message ? message : _.get('message', meta)
|
||||
const msgToSave = message || _.get('message', meta)
|
||||
|
||||
const sql = `insert into server_logs
|
||||
(id, device_id, message, log_level, meta) values ($1, $2, $3, $4, $5) returning *`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue