Drizzle Team

DT

Drizzle Team

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

Join

Prepared queries typings lost after export in monorepo

I'm using SST and I defined my prepared queries in a separate core package to be used across functions in the functions package. The prepared queries are defined like that: ```ts // packages/core/db/preparedQueries.ts...
No description

Nodejs - Typescript Project Build

I am stuck at building typescript node project, When I run tsc I get these errors because of drizzle.

Column Unique name appears to be incorrect when spreading common fields to multiple tables

Came across this issue. Not sure if it's a big deal but i am spreading a common set of timestamp fields around to most of my tables and it looks like the unique name is incorrect. It looks like all my tables have this 'organizations_created_at_unique' naming convention on them with the unique field ```ts [ 'created_at', 'PgTimestamp', 'organizations_created_at_unique' ], [ 'updated_at', 'PgTimestamp', 'organizations_updated_at_unique' ],...
No description

Nested Relations Where has Zero Typings :confused:

Hey guys - first post so please let me know if this isn't the wrong place or I'm doing something wrong. Anyhow, I'm trying to order a simple nested relation in a query: ``` await db.query.channel.findMany({ with: {...
No description

on every `migrate()`: schema "drizzle" already exists, skipping

Hi there! I have setuped a postgres DB. Everytime I call migrate(), it works and migrates, but returns these two warnings: ```bash { severity_local: 'NOTICE',...

onConflictDoUpdate() ID entry

How to get ID of entry in onConflictDoUpdate, where conflict appeared?

Strugling to use composite key in schema

How do I represent composite primary key in drizzle way (sqlite) below migration query? I red the docs but failed miserable in trying to implement it. ```CREATE TABLE QuestionSetMapping ( SetID INTEGER, QuestionID INTEGER, PRIMARY KEY(SetID, QuestionID),...

Get database informations inside 'use client' component

Hello, i would like to display categories from my database in my 'use client" component, how can i do ? i don't understand why i have this error when calling database: Module not found: Can't resolve 'net'...

Running migrate() in Sveltekit project

I have a migrate.ts file with the script for running migrate(), how would you typically execute this in a sveltekit project? I tried adding it to a npm script: "migrate": "ts-node src/lib/server/database/migrate.ts" but I get errors here (ERR_UNKNOWN_FILE_EXTENSION). Any ideas?

Reference to auth.users?

i was following ben davis video about sveltekit + supabase/drizzle. in his video he mention that he want to use sql file in supabase/migrations as a source of truth and then rewrote it in schema.ts, ``` create table profile ( id serial primary key, first_name varchar(100),...

Are postgres CONSTRAINTS supported when creating a table schema?

In the column builder types I see there's a general assumption of name, dataType, columnType. In contrast the actual Postgres CREATE TABLE syntax is very rich: https://www.postgresql.org/docs/current/sql-createtable.html...

Optional/Default value for Relational `Extras`

I have a couple cases where a default/optional value for "extras" in the relational query builder could come in handy. I only really want to run this if the user is logged in. ATM I have the following solution ```ts extras(fields, operators) { return {...

import { PostgresError } from "postgres" - build error?

I'm getting build error when i try to import PostgresError from postgres It says The requested module 'postgres' does not provide an export named 'PostgresError' during build but I am getting no typescript error on my code. I have code like this ```ts...
No description

How to do this query in one step instead of two?

Is there a better way to do this than having two different queries? // gets all posts for a specific user with only a users name passed in. `export default async function getAllPosts( userName: string...

How to query from a many to many relationship?

Hi all, I am trying to get all the posts by a user. My schema has a many-to-many relationship set up for posts and users. ...

Correct way to deal with MySqlRawQueryResult

What is best practice to check if the data was created and how to get the newly added data? ``` db.insert(user).values({ firstname: data.data.firstname, lastname: data.data.lastname,...

Unknown option schemaFilter for drizzle-kit introspect

The documentation https://orm.drizzle.team/kit-docs/commands#introspect--pull states that there is a schemaFilter option to specify the database schema parameter. I have installed the newest drizzle-kit: ```...

How are you all seeding your database?

I see a question from back in March (5 months ago -- https://discord.com/channels/1043890932593987624/1088404663344316476 -- ) answered that it 's planned for in-code custom migrations. IMO seeding from within migrations isn't great, and is actually warned against in some other stacks (eg: Rails). I've fiddled around a bit this morning, trying to get a basic "hello world" ts-node script to run and load my ''src/lib/db" to get connection and schema, but had no luck. It seems like this should be an easy thing, to simply have a stand-alone script that could load up the drizzle-orm connection and schema, and use them to insert some data. Can I get a pointer in the right direction? Thanks!!...

Why it's not possible to use `where` here?

I'm trying to make a PoC for drizzle and I'm converting some sequelize to Drizzle, but I don't really have experience with databases to be honest with you. I can't understand, why using where is not possible in this case. Seems like I don't quite understand how to describe BelongsTo with Drizzle and that might be a problem. Can you guys help? Thanks...
No description

optional parent child relationship on same table

Hi all I have a table called 'comments' Some comments will have a parent comment, while others will not....