Drizzle Team

DT

Drizzle Team

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

Join

hashing password in Cloudflare Workers

Can someone help me find function to hash password and verify it that works in Cloudflare Workers

How to get the count of records? Here is my normal sql, trying to translate into drizzle

```.select({ id: comments.id, parentId: comments.parentId, // TODO countReplies: get the comment count where this id is listed as the parentId of other comments (...

Is there a way to create check constraint?

I need to have a check constraint in my schema. I know check function is currently not supported, but is there a way to hack our way into implementing it?

How to add to the database where the table has a many relationship to another table

I have a users table, which has a many relationship to to a posts table. I want to add a new user to the table, which I can do, but how do I go about adding new posts to that user? Does it add a full post object to the user? Or just an id to the new post which will be in the post table? `export const users = pgTable('users', {...

Where clauses across multiple tables in relational queries

Is is possible to specify a where condition in a relational query that includes conditions from the primary table and one or more relations? e.g. ```ts {...

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...