UNPKG

@designliquido/lincones-postgresql

Version:
29 lines 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RetornoComando = void 0; class RetornoComando { constructor(resultadoExecucao) { this.linhasAfetadas = 0; this.linhasRetornadas = []; this.tiposDeComandos = ['INSERT', 'UPDATE', 'DELETE']; if (!resultadoExecucao) { return; } if (resultadoExecucao.rowCount) { this.linhasAfetadas = resultadoExecucao.rowCount; } if (this.tiposDeComandos.includes(resultadoExecucao.command)) { this.comandoExecutado = resultadoExecucao.command; this.mensagemExecucao = `Ok (${this.linhasAfetadas} ${this.linhasAfetadas > 1 ? 'linhas afetadas' : 'linha afetada'})`; return; } if (resultadoExecucao.command === 'SELECT') { const linhas = resultadoExecucao.rows.length || 0; this.linhasRetornadas = resultadoExecucao.rows; this.mensagemExecucao = `(${linhas} ${linhas > 1 ? 'linhas retornadas' : 'linha retornada'})`; return; } } } exports.RetornoComando = RetornoComando; //# sourceMappingURL=retorno-comando.js.map