@jpmart/nx-drizzle
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

nx-drizzle

This is an Nx plugin for Drizzle integration. It helps you to generate the Drizzle configuration file for an application, and it adds the target for running the drizzle-kit cli.

Why

Because inside an Nx workspace there are a couple of things to keep in mind when setting up Drizzle. This plugin aim to streamline and enforce a good pattern for using Drizzle inside an Nx workspace. Those are:

  • Write a drizzle config file for each application
  • Add all the targets for running the drizzle-kit cli against the drizzle config file for that application
  • Use the Nx dependency graph to automatically include all the schema files in the drizzle config (Automatic schema detection, see below)

Automatic schema detection

Sometimes you want to devide your application is a series of self contained modules. This plugin using the Nx dependency graph will include in your drizzle config the paths of all the shema files inside your workspace and node_modules. To do so it will add to the schema globs list all the files called schema.ts that are present in all of the application's dependencies. This way you can use the drizzle-kit cli to generate the migrations without importing and re-exporting all the table definitions and relations. Furthermore, if you have multiple feature libs that are used by multiple apps, you will generate migrations only for the imported tables. See the example directory.

To disable this feature just comment out in the drizzle config generated by this plugin the retriveGlobsForDrizzleSchemaForProject function then provide you own schema globs.

Building

Run nx build nx-drizzle to build the library.

Running unit tests

Run nx test nx-drizzle to execute the unit tests via Jest.

Readme

Keywords

none

Package Sidebar

Install

npm i @jpmart/nx-drizzle

Weekly Downloads

1

Version

0.0.3

License

none

Unpacked Size

26.1 kB

Total Files

24

Last publish

Collaborators

  • jacopo_patroclo