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

Version 2.0 Notice #139

Open
rmp135 opened this issue Mar 16, 2024 · 0 comments
Open

Version 2.0 Notice #139

rmp135 opened this issue Mar 16, 2024 · 0 comments

Comments

@rmp135
Copy link
Owner

rmp135 commented Mar 16, 2024

Hi all,

First off, sorry for the radio silence, just haven't been feeling motivated but I'm back and have been chipping away on a total overhaul.

Version 2.0 is here and there's a number of changes I'd like to go over.

  • Exports as ES module
  • Integrated testing for each DB provider using testcontainers
  • Support for MySQL enums (converts to string union)
  • Fluent API for node
  • Mapping functions for cleaner customisation
  • Modernised testing and framework using Vitest and GitHub actions

Migration Guide

Because it now exports as an ES module, consumer projects must also be of type module.

The biggest change is how the node module now works. Previously it was a couple of random functions that I never quite liked. Now, it uses a fluent API to chain operations together. See the node module docs for more details.

import { Client } from '@rmp135/sql-ts'

const config = { }

const ts = await Client
  .withConfig(config)
  .fetchDatabase()
  .mapColumn('public.users.name', ((column, table, schema) => ({ ...column, propertyName: 'newName' })))
  .toTypescript()

For CLI users, there's no specific changes required, however please report if you find anything untoward.

For those with custom templates:

  • The full config is now passed in as a parameter so the previous custom block becomes config.custom.
  • The main database object is a now an object with an array of schemas, each with a name, namespaceName and list of tables and enums.

The folder config option has been removed, just use filename with a path.

@rmp135 rmp135 pinned this issue Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant