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

Generate typescript comments based on columns comments #127

Closed
maktouch opened this issue Jan 3, 2024 · 1 comment · Fixed by #139
Closed

Generate typescript comments based on columns comments #127

maktouch opened this issue Jan 3, 2024 · 1 comment · Fixed by #139
Labels
feature request New feature or request

Comments

@maktouch
Copy link

maktouch commented Jan 3, 2024

Most databases support having a comment field for each columns. We could extract the comment, and output it to the definition file.

Example:

This schema

CREATE TABLE `customer_metrics` (
  `company_id` bigint unsigned NOT NULL,
  `date` date NOT NULL,
  `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `customer_email` text,
  `remote_customer_id` varchar(255) NOT NULL,
  `mrr` decimal(16,4) DEFAULT NULL COMMENT 'Monthly Recurring Revenue in USD',
  `ltv` decimal(16,4) DEFAULT NULL COMMENT 'Lifetime Value in USD',
  PRIMARY KEY (`company_id`,`date`),
  KEY `customer_metrics_date` (`date`),
  KEY `customer_metrics_company_id` (`company_id`),
  KEY `customer_metrics_remote_customer_id` (`remote_customer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

would output this:

export interface CustomerMetrics {
  company_id: number
  customer_email: string | null
  date: Date
  /**
   * Lifetime Value in USD
   */
  ltv: Decimal | null
  /**
   * Monthly Recuring Revenue in USD
   */
  mrr: Decimal | null
  remote_customer_id: string
  updated_at: Generated<Date>
}

which would enable this:

image

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
@RobinBlomberg
Copy link
Owner

This is a great idea! This should definitely be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants