How to use generated "Indentifier" type? #444
-
When Kanel autogenerates the types for tables with relations it produces the following; /** Identifier type for app.Carts */
export type CartsId = string & { __brand: 'CartsId' }
export default interface Carts ...
export interface CartsInitializer ...
export interface CartsMutator ... which then when used always produces a typescript error because the string will never match the object part and viceversa. How then do I go about using the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
When inserting/updating, you have to "convert" your plain string to a It was recently requested that the branded id's should be optional, which it seems several people prefer. I just find them incredibly useful. |
Beta Was this translation helpful? Give feedback.
When inserting/updating, you have to "convert" your plain string to a
CartsId
somewhere, simply by casting:const cartsId = '1' as CartsId;
.It was recently requested that the branded id's should be optional, which it seems several people prefer. I just find them incredibly useful.