Styling basics

This commit is contained in:
2024-05-11 00:59:50 +03:00
parent 14ce3c0662
commit dac057c052
25 changed files with 1277 additions and 52 deletions
+7 -5
View File
@@ -31,7 +31,7 @@ const updateCategoryCache = cacheUpdater(cache);
/**
* @param {import('postgres').Sql} sql
* @param {number[]} user_ids
* @param {number[] | undefined} user_ids
* @returns {Promise<Result<Category>>}
*/
export const getCategoriesCached = cachedMethod(cache, getCategories);
@@ -40,16 +40,18 @@ export const getCategoriesCachedByRef = refExtendCachedMethod(getCategoriesCache
/**
* @param {import('postgres').Sql} sql
* @param {number[]} category_ids
* @param {number[] | undefined} category_ids
* @returns {Promise<Result<Category>>}
*/
export async function getCategories(sql, category_ids) {
if (category_ids.length == 0) return new Map();
export async function getCategories(sql, category_ids = undefined) {
if (category_ids !== undefined && category_ids.length == 0) return new Map();
const filter = category_ids ? sql`WHERE id IN ${ sql(category_ids) }` : sql``;
const query = sql`
SELECT id, name
FROM doki8902.post_category
WHERE id IN ${ sql(category_ids) };`;
${ filter };`;
let categories = await query;