DT
Drizzle Teamwanitoo
Postgres functions in the ORM?
Hello everyone, I'm learning typescript and SQL (with drizzle) and I'm trying to make an api endpoint that has something like this
I'm updating attributes (name, owner, hidden...) that are sent from a PATCH request and some fields are optional so they could be null/undefined. COALESCE() here gives the original value in the column if the attributes are null. This sql query works but I would like to ask if its possible to do this without calling sql`` operator. Earlier i tried something like
But it did not let me compile, giving me this error instead
If there is a better way to go about what I'm trying to do, any help would be greatly appreciated!
Angelelz•246d ago
This is how I would do it:
Now, I currently don't have anywhere to test this on but you get the idea.
wanitoo•246d ago
this is way cleaner than what i was currently doing. Thank you!
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
7.4KMembers
View on DiscordWant results from more Discord servers?
More PostsInferModelFromColumns with columns defined with sql``Let's say I have a select list that looks like this
```ts
const defaultBookFields = {
id: books.Issue with drizzle-zod?Schema
```
export const testinArray = pgTable("testing_array", {
id: varchar("id", { length: 14 Optional One-to-One RelationCurrently it's possible to define only a One-to-One relation (https://orm.drizzle.team/docs/rqb#one-Having Issues Pushing Database SchemaHi I am getting this issue whenever I am trying to push the database schema. Any help would be greatmigration failedcode:
```js
const migrationClient = postgres("postgresql://jer:admin@localhost:5432/test", { max: 1TypeError: Cannot read properties of undefined (reading 'compositePrimaryKeys')I am attempting to run db push, but I am getting this error above^^
does anyone know what might be Nesting sqlite drizzle into a deeper location in my ts app, difficulties with src/ vs dist/Hey! I'm very new to drizzle and trying to set up a very small drizzle instance for a service that rsyntax highlighting not workingI reinstalled the node_modules multiple times and it didnt fix my problem. This isnt suposed to look