Feat: change column "detail" in database to use jsonb

This commit is contained in:
Cesar 2020-12-21 18:16:41 +00:00 committed by Josh Harvey
parent 82916388a0
commit c16e47af96
3 changed files with 73 additions and 51 deletions

View file

@ -77,6 +77,16 @@ const batchInvalidate = (ids) => {
return db.none(sql, [formattedIds])
}
const clearBlacklistNotification = (cryptoCode, cryptoAddress) => {
const sql = `UPDATE notifications SET valid = 'f', read = 't' WHERE type = 'compliance' AND detail->>'cryptoCode' = $1 AND detail->>'cryptoAddress' = $2 AND (detail->>'code' = 'BLOCKED' OR detail->>'code' = 'REUSED')`
return db.none(sql, [cryptoCode, cryptoAddress])
}
const getValidNotifications = (type, detail) => {
const sql = `SELECT * FROM notifications where type = $1 AND valid = 't' AND detail @> $2`
return db.any(sql, [type, detail])
}
module.exports = {
machineEvents: dbm.machineEvents,
addNotification,