providerrefactor part1
This commit is contained in:
25
src/providers/sqlite3/queries/posterminal.js
Normal file
25
src/providers/sqlite3/queries/posterminal.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import * as source from '../../mssql/queries/posterminal.js';
|
||||
import { translateQueries } from './translate.js';
|
||||
|
||||
const queries = translateQueries(source, 'posterminal');
|
||||
export const {
|
||||
CREATE, DELETE_BY_COMPANY_AND_ID, GET_BY_ID, LIST_BY_COMPANY,
|
||||
LIST_CATEGORY_IDS, POSTERMINAL_IDS_BY_COMPANY, SET_OFF, SET_OFF_ALL, UPDATE,
|
||||
} = queries;
|
||||
|
||||
export const SET_ON = `
|
||||
INSERT INTO posterminalcategory (posterminal_id, category_id)
|
||||
VALUES (@posterminalId, @categoryId)
|
||||
ON CONFLICT (posterminal_id, category_id) DO NOTHING
|
||||
`;
|
||||
|
||||
export const SET_ON_ALL = `
|
||||
WITH RECURSIVE cats AS (
|
||||
SELECT id FROM category WHERE id = @rootCategoryId
|
||||
UNION ALL
|
||||
SELECT c.id FROM category c INNER JOIN cats ON c.parent_id = cats.id
|
||||
)
|
||||
INSERT INTO posterminalcategory (posterminal_id, category_id)
|
||||
SELECT @posterminalId, id FROM cats WHERE 1
|
||||
ON CONFLICT (posterminal_id, category_id) DO NOTHING
|
||||
`;
|
||||
Reference in New Issue
Block a user