Skip to content

Commit

Permalink
feat: implements kysely type filter
Browse files Browse the repository at this point in the history
  • Loading branch information
rhyzzor committed Dec 11, 2024
1 parent 5c1d938 commit dcd7b68
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/kanel-kysely/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,17 @@ module.exports = {
preRenderHooks: [makeKyselyHook(), kyselyCamelCaseHook],
};
```

## Type Filter

If you're using Kysely for migrations, you might want to filter the types of the migration tables, such as `kysely_migration` and `kysely_migration_lock`. The `kyselyTypeFilter` will do this for you.

```ts
const { kyselyTypeFilter } = require("kanel-kysely");

module.exports = {
/// ... your config here.

typeFilter: kyselyTypeFilter,
};
```
1 change: 1 addition & 0 deletions packages/kanel-kysely/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { kyselyCamelCaseHook } from "./kyselyCamelCaseHook";
export { kyselyTypeFilter } from "./kyselyTypeFilter";
export { default as makeKyselyHook } from "./makeKyselyHook";
4 changes: 4 additions & 0 deletions packages/kanel-kysely/src/kyselyTypeFilter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { PgType } from "extract-pg-schema";

export const kyselyTypeFilter = (table: PgType): boolean =>
!["kysely_migration", "kysely_migration_lock"].includes(table.name);

0 comments on commit dcd7b68

Please sign in to comment.