u
This commit is contained in:
22
src/store/posterminal/findByPairingpin.js
Normal file
22
src/store/posterminal/findByPairingpin.js
Normal 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;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user