This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
update table1 t1 | |
set "order" = t2.seq | |
from ( | |
select id, row_number () over (partition by target_id order by created_at) as seq | |
from table2 | |
) as t2 | |
where t1.id = t2.id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type VariantValue<T> = { [K in keyof T]?: keyof T[K] } | |
type Variant = { [k: string]: string } | |
type VariantConfig = { [k: string]: Variant } | |
const cns = <T extends VariantConfig>(base: string, variantsConfig?: T, defaultVariants: VariantValue<T> = {}) => (variantsValues: VariantValue<T> = {}): string => { | |
const variants = Object.entries(variantsConfig || {}).map(([name, values]) => values?.[variantsValues[name] || defaultVariants[name]] ?? '') | |
return [base, ...variants].filter(Boolean).join(' ') | |
} | |
const button = cns( |
OlderNewer