Drizzle Team

DT

Drizzle Team

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

Join

How to retrieve database credentials from drizzle.config.ts

I'm attempting to retrieve Neon database credentials dynamically from drizzle.config.ts , instead of saving them in a .env, by running drizzle-kit push. The issue, both methods I tried rely on top-level await and throw Top-level await is currently not supported with the "cjs" output format exception. 1. @aws-sdk/client-ssm example: ``` const { SSMClient, GetParameterCommand } = require("@aws-sdk/client-ssm");...

How to query todos from multiple lists/all lists

Using drizzle ORM and SvelteKit, how do I select todos from multiple lists or all lists? Right now this query function only allows me to query 1 list. I'm still an amateur trying to figure out SvelteKit and Drizzle. Appreciate the help!...
No description

mysql 5.7.4 lateral issues

Mysql 5.7.4 doesn't include the lateral joins which is the default for drizzle query builder. Is there anyway to tell drizzle not to use lateral joins so I can use the query builder?...

Extracting the Query "With" Type

As title said I'm trying to extract the with type of a query, I tried out a bunch of stuff with no luck so far.
const query = db.user.findFirst({ with: This Type})
const query = db.user.findFirst({ with: This Type})
...

Table foreign key action fields

Hello, I'd like to use the new foreignKey option inside the table config so that I do not have issues with the identifier being longer than allowed. Is there a way to achieve this whilst also setting the onCascade and onUpdate action properties like you could previously with the .references() syntax? I tried leaving both of them in place (like in the code below) with the hope that it would only generate one foreign key with my name provided and the actions I set with references() but it generates two constraints in the SQL migration file, one with my custom identifier and no actions and one with the default generated constraint name (too long for my DB) and with the actions. I didn't really expected this to work but It would be good to know the best approach going forward to set the custom FK name and also set the actions. Perhaps it is something missed with the latest update for the new foreignKey() functionality? (I could always just change the migration file manually, like I had previously been doing for the foreign key names which were too long but they kept coming back in future migrations with the default generated name, presumably because the _journal.json files have references to the generated fk names which I had overwritten?)...

Decimal Inferred is a string

Any idea why my decimal is being inferred as a string instead of a number?
Solution:
This is correct behavior. The problem is that decimal can have a lot more decimals than a JS number. See here for more info https://github.com/drizzle-team/drizzle-orm/issues/1026#issuecomment-1694040929
No description

error with ILIKE on libsql

I'm trying to use ILIKE clause on libsql and I receive a error. Repository to reproduce the error: https://github.com/emersonlaurentino/libsql-ilike-error...

Dynamic query building

I'm trying to replicate the documentation and create a withPagination function using query building, but the types are causing an error. https://orm.drizzle.team/docs/dynamic-query-building...
No description

Another SSL error on import

I have an existing database and I wanted to try drizzle on it. Database is from a lesser known provider and is impossible to find reliable help to access it, but unfortunately I cannot change it. I want to use drizzle-kit introspect:pg here is my drizzle.config.ts...

Confusing error with neon

Hi all! Just setup a project with drizzle (via create-t3-app) but I get this odd, vague error when I try to push my schema to my neon db. Any ideas on how to even begin debugging this? ```$ dotenv drizzle-kit push:pg drizzle-kit: v0.19.13 drizzle-orm: v0.28.6 ...

Generate Random UUID Sqlite

Hey i was wondering how i would create a unique ID that contains a random string of characters for a text?
model User {
id String @id @default(uuid())
}
model User {
id String @id @default(uuid())
}
Something like this but instead of mysql and primsa. Have Sqlite and Drizzle...

Logging query time

Is it possible to log query time? I see that the current logger implementation sends the sql and the params of sql but I couldn't find anything which lets me see the time it took to run the query

[How To?] Generate uuids properly on cloudflare d1 sqlite...

I am running an app with Drizzle, TRPC, and Cloudflare D1 sqlite database: My initial project databasse schema looks like: ``` export const CarTable = sqliteTable('Car', {...

Dropping primary keys every time

so latest drizzle-kit fixed a bunch of issues with dropping indexes and preserving pk order but it's still dropping and recreating PKs every time `` ALTER TABLE account` DROP PRIMARY KEY;...

need help abstracting a function

This may be an easy answer but how can I implement the following type? ```typescript export const getUserWithEmail = (email: string, withConfig: any) => { return db.query.usersTable.findFirst({...

Does drizzle support `disconnect` relations ?

Does drizzle support disconnect feature on relations during update query similar to prisma ?

binary columns in drizzle studio

I have implemented the following custom type for storing blockchain addresses: ```typescript const address = customType<{ data: string; driverData: Buffer }>({ dataType: () => 'BINARY(20)', fromDriver(value) {...
No description

Access values in "where" query

Hey, so I wan't to do some calculations, specifically geo radius. How can I access the data while doing the query? ```ts const res = await db.query.apartments.findMany({ where: (apartment, { lte }) => { const long = apartment.long...

Unable to delete from many to many relationship due to FK constraint

I have the following schema, Users <> Teams - many to many usersOnTeams - table to hold this relationship ...