You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeScript users, here's a cool new feature! Starting from v2.48.0, defining custom types for JSON fields in supabase-js and using them with the JSON selector is now easier, making your code more type-safe and intuitive.
Quick Example
Define your custom JSON type:
typeCustomJsonType={foo: string;bar: {baz: number};en: 'ONE'|'TWO'|'THREE';};exporttypeDatabase=MergeDeep<DatabaseGenerated,{your_table: {Row: {data: CustomJsonType|null;};// Optional: Use if you want type-checking for inserts and update// Insert: {// data?: CustomJsonType | null;// };// Update: {// data?: CustomJsonType | null;// };};}>;
What You Get
Now, when you query your data:
constres=awaitclient.from('your_table').select('data->bar->baz, data->en, data->bar');if(res.data){console.log(res.data);// TypeScript infers the shape of your JSON data:// [// {// baz: number;// en: 'ONE' | 'TWO' | 'THREE';// bar: { baz: number };// }// ]}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
TypeScript users, here's a cool new feature! Starting from v2.48.0, defining custom types for JSON fields in
supabase-js
and using them with the JSON selector is now easier, making your code more type-safe and intuitive.Quick Example
Define your custom JSON type:
What You Get
Now, when you query your data:
Get Started
Start using this feature with our guides:
Beta Was this translation helpful? Give feedback.
All reactions