u
This commit is contained in:
27
src/store/posterminal/setMaxKnownTombstoneId.js
Normal file
27
src/store/posterminal/setMaxKnownTombstoneId.js
Normal file
@@ -0,0 +1,27 @@
|
||||
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,
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user