How do you use an Enum in your model? #87
Answered
by
NateWritesCode
NateWritesCode
asked this question in
Q&A
-
Hello, I was wondering how to incorporate an Enum into a model? Would it be best to be explicit using the type of data contained in the Enum (i.e. String)?
Or is there a way to make it work using the t.field function?
Thanks for the awesome library! |
Beta Was this translation helpful? Give feedback.
Answered by
NateWritesCode
Jun 22, 2021
Replies: 1 comment 2 replies
-
Figured it out... First, create an enumType as part of your model
Second, can use t.field like so...
|
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
NateWritesCode
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Figured it out...
First, create an enumType as part of your model
export const ChatStatusEnumType = enumType(ChatStatus);
Second, can use t.field like so...
t.field(Saver.chatStatus.name, { type: ChatStatus.name });