Files
dashlibstorage/src/providers/mssql/queries/printeragent.js
2026-10-30 16:48:36 +01:00

59 lines
1.2 KiB
JavaScript

export const PRINTERAGENT_COLUMNS = `
id,
company_id AS companyId,
name,
token,
pairingpin,
paired_at AS pairedAt,
clientserial,
clientmodel,
clientstate,
agentversion,
lastseen_at AS lastseenAt,
updated_at AS updatedAt
`;
export const LIST_BY_COMPANY = `
SELECT
${PRINTERAGENT_COLUMNS}
FROM printeragent
WHERE company_id = @companyId
ORDER BY name, id
`;
export const GET_BY_COMPANY_AND_ID = `
SELECT
${PRINTERAGENT_COLUMNS}
FROM printeragent
WHERE id = @id AND company_id = @companyId
`;
export const CREATE = `
INSERT INTO printeragent (company_id, name, pairingpin)
OUTPUT
INSERTED.id,
INSERTED.company_id AS companyId,
INSERTED.name,
INSERTED.token,
INSERTED.pairingpin,
INSERTED.paired_at AS pairedAt,
INSERTED.clientserial,
INSERTED.clientmodel,
INSERTED.clientstate,
INSERTED.agentversion,
INSERTED.lastseen_at AS lastseenAt,
INSERTED.updated_at AS updatedAt
VALUES (@companyId, @name, @pairingpin)
`;
export const UPDATE_NAME = `
UPDATE printeragent
SET name = @name, updated_at = SYSUTCDATETIME()
WHERE id = @id AND company_id = @companyId
`;
export const DELETE_BY_COMPANY_AND_ID = `
DELETE FROM printeragent
WHERE id = @id AND company_id = @companyId
`;