This commit is contained in:
seb
2026-09-29 11:21:57 +02:00
parent 5d2c8fdfed
commit 7bb674d5e7
10 changed files with 123 additions and 7 deletions

View File

@@ -0,0 +1,22 @@
import { FIND_BY_PAIRINGPIN as MSSQL_FIND } from '../../providers/mssql/queries/posterminal.js';
import { FIND_BY_PAIRINGPIN as SQLITE_FIND } from '../../providers/sqlite3/queries/posterminal.js';
import makeRunner from '../runner.js';
export default function findByPairingpin(provider) {
const sql = provider?.dialect === 'sqlite3' ? SQLITE_FIND : MSSQL_FIND;
/**
* Finds a posterminal by its pairingpin.
*
* @param {string} pairingpin - The pairing pin to search for.
* @param {object} [tx] - Optional transaction to run within.
* @returns {Promise<object|null>} The posterminal row, or null if not found.
*/
return async (pairingpin, tx) => {
if (!pairingpin) return null;
const result = await makeRunner(provider, tx).query(sql, {
pairingpin: String(pairingpin).trim(),
});
return result.rows[0] || null;
};
}