Skip to content

[Pg[: Add pgEnumCreator function#5137

Open
scinscinscin wants to merge 1 commit intodrizzle-team:mainfrom
scinscinscin:main
Open

[Pg[: Add pgEnumCreator function#5137
scinscinscin wants to merge 1 commit intodrizzle-team:mainfrom
scinscinscin:main

Conversation

@scinscinscin
Copy link
Copy Markdown

This function allows users to prefix their enums like they do with pgTableCreator.

It also implements a test to make sure that it creates the enum object properly with the correct name.

pg-core/columns/enum.ts

export function pgEnumCreator(customizeTableName: (name: string) => string): typeof pgEnum {
	// @ts-ignore
	return (_enumName: string, input: any) => {
		return pgEnum(customizeTableName(_enumName), input);
	};
}

The usecase for this function should be similar for usecases for pgTableCreator, which i use in projects so that I can have more than 1 project use the same database in Neon free tier.

Please let me know if there are things that can be improved. I am unsure if the test that I wrote is correct since each test is supposed to be an integration test, what I made is more of a unit test.

This function allows users to prefix their enums like they do with pgTableCreator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant