Prepared Statements
Automatic creation, cached and re-used by connection
Similar to connection.query()
.
connection.execute('select 1 + ? + ? as result', [5, 6], (err, rows) => {
// rows: [ { result: 12 } ]
// internally 'select 1 + ? + ? as result' is prepared first. On subsequent calls cached statement is re-used
});
// close cached statement for 'select 1 + ? + ? as result'. noop if not in cache
connection.unprepare('select 1 + ? + ? as result');