Files
dashlibstorage/src/providers/mssql/queries/printer.js
2026-09-26 23:06:05 +02:00

100 lines
1.6 KiB
JavaScript

export const PRINTER_COLUMNS = `
id,
company_id,
address,
type,
model,
serial,
sort,
[desc]
`;
export const LIST_BY_COMPANY = `
SELECT
${PRINTER_COLUMNS}
FROM printer
WHERE company_id = @companyId
ORDER BY sort ASC, id ASC
`;
export const GET_BY_COMPANY_AND_ID = `
SELECT
${PRINTER_COLUMNS}
FROM printer
WHERE id = @id AND company_id = @companyId
`;
export const GET_NEXT_SORT = `
SELECT ISNULL(MAX(sort), -1) + 1 AS sort
FROM printer
WHERE company_id = @companyId
`;
export const LIST_IDS_BY_COMPANY = `
SELECT id
FROM printer
WHERE company_id = @companyId
`;
export const CREATE = `
INSERT INTO printer (
company_id,
address,
type,
model,
serial,
sort,
[desc]
)
OUTPUT
INSERTED.id,
INSERTED.company_id,
INSERTED.address,
INSERTED.type,
INSERTED.model,
INSERTED.serial,
INSERTED.sort,
INSERTED.[desc]
VALUES (
@companyId,
@address,
@type,
@model,
@serial,
@sort,
@desc
)
`;
export const UPDATE = `
UPDATE printer
SET
address = @address,
type = @type,
model = @model,
serial = @serial,
sort = @sort,
[desc] = @desc
OUTPUT
INSERTED.id,
INSERTED.company_id,
INSERTED.address,
INSERTED.type,
INSERTED.model,
INSERTED.serial,
INSERTED.sort,
INSERTED.[desc]
WHERE id = @id AND company_id = @companyId
`;
export const UPDATE_SORT = `
UPDATE printer
SET sort = @sort
WHERE id = @id AND company_id = @companyId
`;
export const DELETE_BY_COMPANY_AND_ID = `
DELETE FROM printer
WHERE id = @id AND company_id = @companyId
`;