This commit is contained in:
seb
2026-08-01 02:15:21 +02:00
parent 59c874144b
commit 69a24192d3
8 changed files with 206 additions and 0 deletions

View File

@@ -8,3 +8,25 @@ export const ADD = `
INSERT INTO articlepic (article_id, pic_id, sort)
VALUES (@articleId, @picId, @sort)
`;
export const LIST_HASHES_BY_ARTICLE = `
SELECT p.hash AS fullHash
FROM articlepic ap
INNER JOIN pic p ON p.id = ap.pic_id
WHERE ap.article_id = @articleId
ORDER BY ap.sort ASC, ap.id ASC
`;
export const SET_TEMP_SORTS = `
UPDATE articlepic
SET sort = -id
WHERE article_id = @articleId
`;
export const UPDATE_SORT_BY_HASH = `
UPDATE ap
SET sort = @sort
FROM articlepic ap
INNER JOIN pic p ON p.id = ap.pic_id
WHERE ap.article_id = @articleId AND p.hash = @fullHash
`;