For anyone considering the use of ULIDs in MySQL with drizzle
, here's a ready-to-use ULID
type for your convenience.
import { Ulid as ULID } from "id128";
export const ulid = customType<{
data: string;
notNull: true;
default: false;
// P.S. the real moeny is at the buttom of the file | |
import { getTableColumns, type Table } from "drizzle-orm"; | |
/** | |
* Creates a column selector for a given Drizzle ORM table. | |
* | |
* This function allows for flexible selection and omission of columns from a table. | |
* | |
* @param table - The Drizzle ORM table to create a column selector for. |
For anyone considering the use of ULIDs in MySQL with drizzle
, here's a ready-to-use ULID
type for your convenience.
import { Ulid as ULID } from "id128";
export const ulid = customType<{
data: string;
notNull: true;
default: false;
In this post, I'm going to share an approach I used to design a role-based access control system with TypeScript. The unique aspect of this system is the shared permissions config, which can be utilized both on the backend (for access control) and on the frontend (for UI control). The main idea is to design a robust and type-safe system that ensures users have the correct permissions for their tasks.
Firstly, I define several roles representing different types of users within the system:
export type Role = 'owner' | 'admin' | 'manager' | 'user';