Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different Naming #211

Open
jakobsuckow opened this issue Oct 23, 2024 · 4 comments
Open

Different Naming #211

jakobsuckow opened this issue Oct 23, 2024 · 4 comments
Labels
in progress We're working on it

Comments

@jakobsuckow
Copy link

jakobsuckow commented Oct 23, 2024

Hey there,

big fan of this library. Wondering if there is a way of adding a suffix to each Column ? I.e. suffix "Model" would result in


export type Generated<T> = T extends ColumnType<infer S, infer I, infer U>
  ? ColumnType<S, I | undefined, U>
  : ColumnType<T, T | undefined, T>;

export type Timestamp = ColumnType<Date, Date | string, Date | string>;

export interface CompanyModel {
  id: Generated<number>;
  name: string;
}

export interface UserModel {
  company_id: number | null;
  created_at: Generated<Timestamp>;
  email: string;
  id: Generated<number>;
  is_active: boolean;
  name: string;
  updated_at: Timestamp;
}

export interface DB {
  company: CompanyModel;
  user: UserModel;
}

Much appreciated

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@vrachev
Copy link

vrachev commented Nov 22, 2024

Was looking for this myself as well. A workaround is to import User as UserModel in a different file and export UserModel for wider consumption.

Some sort of column naming option would be great though.

@RobinBlomberg have you started working on this (asking bc you've added the 'in-progress' label)? If not I may have some time to take a stab

@RobinBlomberg
Copy link
Owner

RobinBlomberg commented Nov 22, 2024

Hello @vrachev. I'm currently working on a branch that adds:

  • Configuration file support (e.g. .kysely-codegenrc.json)
  • Improved support for custom singularization rules, which adds a way to e.g. add the suffix Model to all table names (slightly hacky, but it works)
  • Custom serializer support, which makes it possible to extend the serializer in a more fine-grained manner and have full control of how e.g. table names are serialized

I haven't had the chance to finalize this yet, but it's working well so far.

@vrachev
Copy link

vrachev commented Nov 22, 2024

Awesome! No rush. Appreciate the great work.

@noudadrichem
Copy link

I'm also looking for Prefix or Postfixes on generated types. Love the library, tyvm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in progress We're working on it
Projects
None yet
Development

No branches or pull requests

4 participants