Drizzle Team

DT

Drizzle Team

The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!

Join

Any easy way to create a typescript ENUM type from pgEnum?

Prisma used to auto-gen all the enum types as well which are heavily used in our application.

Plans to add array related support for Postgres?

+ features to append an object to an array field in postgres?

Migrating from Prisma

Hi, I have an existing project already in production built using prisma and postgres (supabase). I am planning to go serverless and hence planning to migrate to drizzle + PlanetScale. Here is how I am planning it: 1. Use Prisma to generate the entire schema structure in MySQL (Planetscale) 2. Use Drizzlekit to introspect and generate types. 3. Use Drizzle ORM for querying....

Cannot read properties of undefined (reading '0')

What is the expected behavior when using get() when there would be no matching results for a given select query? Does it return null or would this be an error? At present it's giving an error. I'm new to discord, but I guess I expected it to return a null. For example, the following query works and returns an empty array:
db.select().from(users).where(eq(users.email, email)).all();
db.select().from(users).where(eq(users.email, email)).all();
whereas changing all() to get() results in error trying to access first element of an empty array (drizzle-orm/utils.js:40:37):...

Is it recommended to create a SQL transaction every time we try to create a foreign relationship?

prisma used to wrap every foreign upsert (2 entities) within a transaction to guarantee that both rows are created or the changes are rolled back in case of a failure. Is there a way in drizzle to achieve the same? or is it better to individually create the entities?

Doesn't drizzle-kit generate:pg work yet when schema imports from esm package?

```
drizzle-kit generate:pg --out src/db/migrations --schema src/db/schemas
drizzle-kit: v0.17.0 drizzle-orm: v0.23.1...

Is there `.returning()` in insert statement in MySQL like SQLite?

There is .returning() insert statement in SQLite but MySQL not. how do I .returning() in insert statement in MySQL?...

Getting results in document form rather than record

Hi, new to drizzle but liking it so far. Is there away to get the results in more of a 'document' structure? For example, I'd like to get {id: 1, user: "joe", posts: [{id : 1, title: "my first post"},{id : 2, title: "my second post"}]} rather than in record form [{id: 1, user: "joe", post: {id : 1, title: "my first post"}}, ...}]. I'm doing something like select({id ... post: {id: posts.id, title, posts.title}}). Thanks.

Unable to upgrade migrations if there are ones that do not change state but manipulate data

Hi! I have 0.16.x migrations. At some point, I needed to manipulate the data without changing the db structure, so I just made a copy of the latest migration, assigned new ID in snapshot.json and added my sql code. It worked fine, but when I moved to [email protected] and tried to upgrade the migrations, I got the following errors: ``` Everything's fine :dog::fire: {...

require() of ES Module is not supported planetscale serverless + sveltekit

Hi, I am getting this error when I user planetscale serverless with drizzle orm ``` require() of ES Module D:\svelte-edge\node_modules@planetscale\database\dist\index.js from D:\svelte-edge\node_modules\drizzle-orm\planetscale-serverless\session.js not supported. Instead change the require of index.js in D:\svelte-edge\node_modules\drizzle-orm\planetscale-serverless\session.js to a dynamic import() which is available in all CommonJS modules....

Applying migrations with drizzle-orm/pg-core

How would I apply all the migrations that have not yet been applied? I couldn't find any information in the docs...

What is the type for an .orderBy() parameter

Inside of a function, i have a query more complicated than this, but something like:
db.select().from(users).where(...).orderBy(asc(users.username))
db.select().from(users).where(...).orderBy(asc(users.username))
...

MySqlInsertValue<> vs typeof Table type mismatch

I've got this line of code:
await db.insert(table).values(props);
await db.insert(table).values(props);
...

Argument of type 'SQL<unknown>' is not assignable to parameter

I have the following: ```ts const projects = await db .select()...

Stream select

Hey! I'm doing a large select and I'm wondering how to stream the responses for MySql

documented types for the return of `drizzle()` and the return of `mysqlTable()`

my most pressing need is documented types: https://github.com/drizzle-team/drizzle-orm/issues/273 Specifically the 2 that are holding me up right now are how to pass a the mysql2 version of drizzle() (aka a db reference) and a model reference (the result of mysqlTable()) around through my app...

.andWhere()

I know that .andWhere() isn't a function, but I'm wondering if there's a way to start a query in one function, and return it. And then have the receiver be able to continue to add to the where clause? Something like: ```ts...