drizzle-team / drizzle-team/drizzle-orm

[DOCS]: Type defintions when using multiple clients

Open
#3,670 0 comments 0 reactions 0 assignees View on GitHub
docs docs/undocumented
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Enhancement hasn't been filed before.

- [X] I have verified this enhancement I'm about to request hasn't been suggested before.

### Describe the enhancement you want to request

Some users, such as the one in https://github.com/drizzle-team/drizzle-orm/issues/3196, may be using multiple DB drivers for different environments. The thing that most developers would do is create a union type of the two database clients. In the mentioned issue, it would look like this for `pg` and `neon-http`:

```ts
type DB = (NodePgDatabase & { $client: NodePgClient; }) | (NeonHttpDatabase & { $client: NeonQueryFunction; })
```

However, the above leads to buggy behavior. The proper way to type it is the following:

```ts
type DB = PgDatabase & { $client: NodePgClient | NeonQueryFunction };
```

There is no documentation about the above being a solution.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.