-
Hello! I would like to know how to use enums with Orange ORM? From the docs, we have: But I don't see any clue about enums. I would like to have a CREATE TYPE LOCALES_ENUM AS ENUM ('en-US', 'fr', 'it'); Should I do this as a workaround? function validateLocale(value: MaybeUndefined<MaybeNull<string>>) {
if (value === undefined || value === null) return;
if (!(locales as any).includes(value)) throw new Error('Unknown locale');
}
const map = orange
.map((x) => ({
team: x.table('team').map(({ column }) => ({
id: column('id').numeric().primary().notNullExceptInsert(),
lang: column('lang').string().default(baseLocale).validate(validateLocale)
// * ... |
Beta Was this translation helpful? Give feedback.
Answered by
lroal
Jun 2, 2024
Replies: 1 comment 1 reply
-
Enums are not supported today. A validate function will solve it. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Zer0xxxx
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Enums are not supported today.
Yes, it makes sense to support it.
A validate function will solve it.