import ChannelId from '../../ChannelId' ; import EnginePostgres from './EnginePostgres' ; import AbstractTokensDatabase from '../AbstractTokensDatabase' ; export default class PostgresTokensDatabase extends AbstractTokensDatabase < EnginePostgres > { save ( token , channelId ) { return this . engine . exec ( ( client ) => client . query ( 'INSERT INTO token(token, "channelId", kind) VALUES ($1, $2, $3)' , [ token , channelId . toString ( ) , this . kind ] ) ) ; } isPresent ( token ) { return this . engine . exec ( ( client ) => client . query ( 'SELECT COUNT(*) as count FROM token WHERE token=$1' , [ token ] ) ) . then ( ( res ) => ( res . rows [ 0 ] . count > 0 ) ) ; } }