Add name column to posterminal table

- Added required name NVARCHAR(255) NOT NULL column to posterminal schema
- Updated SQL queries (LIST_BY_COMPANY, GET_BY_ID, CREATE, UPDATE) to include name
- Updated upsert store method to validate and persist name
- Updated README with name in method signatures and return types
This commit is contained in:
seb
2026-08-03 06:32:25 +02:00
parent e7c43ab4e7
commit 829ab19f59
4 changed files with 19 additions and 9 deletions

View File

@@ -5,6 +5,10 @@ export default function upsert(pool) {
const access = resolveCompanyAccess(pool);
return async (googleAuthId, companyId, input = {}) => {
const name = input.name?.trim();
if (!name) {
throw new Error('Invalid posterminal');
}
const pairingpin = input.pairingpin?.trim();
if (!pairingpin) {
throw new Error('Invalid posterminal');
@@ -28,22 +32,25 @@ export default function upsert(pool) {
.request()
.input('id', id)
.input('companyId', companyId)
.input('name', name)
.input('token', token)
.input('pairingpin', pairingpin)
.query(UPDATE);
return { id, token, pairingpin };
return { id, name, token, pairingpin };
}
const created = await pool
.request()
.input('companyId', companyId)
.input('name', name)
.input('token', token)
.input('pairingpin', pairingpin)
.query(CREATE);
return {
id: created.recordset[0].id,
name: created.recordset[0].name,
token: created.recordset[0].token,
pairingpin: created.recordset[0].pairingpin,
};