28 lines
1.0 KiB
JavaScript
28 lines
1.0 KiB
JavaScript
import { SET_MAX_KNOWN_TOMBSTONE_ID as MSSQL_SET } from '../../providers/mssql/queries/posterminal.js';
|
|
import { SET_MAX_KNOWN_TOMBSTONE_ID as SQLITE_SET } from '../../providers/sqlite3/queries/posterminal.js';
|
|
import makeRunner from '../runner.js';
|
|
|
|
export default function setMaxKnownTombstoneId(provider) {
|
|
const sql = provider?.dialect === 'sqlite3' ? SQLITE_SET : MSSQL_SET;
|
|
|
|
/**
|
|
* Updates the max known tombstone ID for a POS terminal.
|
|
*
|
|
* @param {number} id - The posterminal id.
|
|
* @param {number|null} maxknowntombstoneid - The highest synced tombstone ID.
|
|
* @param {object} [tx] - Optional transaction to run within.
|
|
* @returns {Promise<{id: number, maxknowntombstoneid: number|null}>}
|
|
*/
|
|
return async (id, maxknowntombstoneid, tx) => {
|
|
await makeRunner(provider, tx).query(sql, {
|
|
id,
|
|
maxknowntombstoneid: maxknowntombstoneid != null ? Number(maxknowntombstoneid) : null,
|
|
});
|
|
|
|
return {
|
|
id,
|
|
maxknowntombstoneid: maxknowntombstoneid != null ? Number(maxknowntombstoneid) : null,
|
|
};
|
|
};
|
|
}
|