FroggyPanda / better-supabase-types

73 stars 13 forks source link

New Feature: Export Insert and Update types #8

Closed TimurKr closed 1 year ago

TimurKr commented 1 year ago

Idea for a new feature:

Export the Insert and Update classes at the end of the file as well. This seems like a pretty simple feature to add, and it would remove the need for complicated imports when dealing with forms.

My suggestion would be to export types related to a table named todo like this:

export type Todo = Database['public']['Tables']['todo']['Row'];
export type InsertTodo = Database['public']['Tables']['todo']['Insert'];
export type UpdateTodo = Database['public']['Tables']['todo']['Update'];

This would allow for:

import type { InsertTodo } from 'database.ts'

type InsertTodos = InsertTodo[]; // In case of doing bulk insert
barrymichaeldoyle commented 1 year ago

I agree, this is a decent add, did a similar think in my library :)

On Thu, 27 Apr 2023 at 14:22, Timur Kramár @.***> wrote:

Idea for a new feature:

Export the Insert and Update classes at the end of the file as well. This seems like a pretty simple feature to add, and it would remove the need for complicated imports when dealing with forms.

My suggestion would be to export types related to a table named todo like this:

export type Todo = Database['public']['Tables']['todo']['Row']; export type InsertTodo = Database['public']['Tables']['todo']['Insert']; export type UpdateTodo = Database['public']['Tables']['todo']['Update'];

This would allow for:

import type { InsertTodo } from 'database.ts'

type InsertTodos = InsertTodo[]; // In case of doing bulk insert

— Reply to this email directly, view it on GitHub https://github.com/FroggyPanda/better-supabase-types/issues/8, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDVHNUT7PTCEYMJH4FZ5QLXDJQJZANCNFSM6AAAAAAXNY57PY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

FroggyPanda commented 1 year ago

Accepted PR #9 👍