François
François
DTDrizzle Team
Created by uri on 3/4/2025 in #help
How should I refactor my transactions?
I will set up a sample project for you. Ill let you know once I set it up. I will set it up using Nestjs but the principle is applicable to any other app ofc
10 replies
DTDrizzle Team
Created by uri on 3/4/2025 in #help
How should I refactor my transactions?
With NestJS its extremly easy
10 replies
DTDrizzle Team
Created by uri on 3/4/2025 in #help
How should I refactor my transactions?
Are you using Nestjs?
10 replies
DTDrizzle Team
Created by François on 4/11/2025 in #help
Correct Client type to pass drizzle client around
const valuesToInsert: InferInsertModel<typeof offerSkills> = {
offerId: offerId,
skillId: skillId,
mandatory: m
};
return this.database.client.insert<typeof offerSkills>(offerSkills).values(valuesToInsert).returning()
const valuesToInsert: InferInsertModel<typeof offerSkills> = {
offerId: offerId,
skillId: skillId,
mandatory: m
};
return this.database.client.insert<typeof offerSkills>(offerSkills).values(valuesToInsert).returning()
This will also give the error:
Object literal may only specify known properties, and 'mandatory' does not exist in type '{ skillId: string; offerId: string; }'.
Object literal may only specify known properties, and 'mandatory' does not exist in type '{ skillId: string; offerId: string; }'.
But the table definition, as seen above includes this column
3 replies
DTDrizzle Team
Created by François on 4/11/2025 in #help
Correct Client type to pass drizzle client around
I am using the client like this: I am using this class in another service like this:
import * as schema from "drizzle/schema"

constructor(private database: DatabaseService<typeof schema>) {}

public addSkillToOffer(skillId: string, offerId: string, m: boolean, opts?: {tx: any}) {
return Try.success(skillId)
.flatMap(skillId => this.existsById(skillId))
.filter(exists => !exists, () => {throw new SkillNotFoundException(skillId)})

.map(() => this.database.client.insert(offerSkills).values({
offerId: offerId,
skillId: skillId,
mandatory: m
}).returning())
}
import * as schema from "drizzle/schema"

constructor(private database: DatabaseService<typeof schema>) {}

public addSkillToOffer(skillId: string, offerId: string, m: boolean, opts?: {tx: any}) {
return Try.success(skillId)
.flatMap(skillId => this.existsById(skillId))
.filter(exists => !exists, () => {throw new SkillNotFoundException(skillId)})

.map(() => this.database.client.insert(offerSkills).values({
offerId: offerId,
skillId: skillId,
mandatory: m
}).returning())
}
The insert call gives me the following type error:
No overload matches this call.
Overload 1 of 2, '(value: { skillId: string | SQL<unknown> | Placeholder<string, any>; offerId: string | SQL<unknown> | Placeholder<string, any>; }): PgInsertBase<PgTableWithColumns<{ name: "offer_skills"; schema: undefined; columns: { ...; }; dialect: "pg"; }>, ... 4 more ..., never>', gave the following error.
Object literal may only specify known properties, and 'mandatory' does not exist in type '{ skillId: string | SQL<unknown> | Placeholder<string, any>; offerId: string | SQL<unknown> | Placeholder<string, any>; }'.
Overload 2 of 2, '(values: { skillId: string | SQL<unknown> | Placeholder<string, any>; offerId: string | SQL<unknown> | Placeholder<string, any>; }[]): PgInsertBase<PgTableWithColumns<{ name: "offer_skills"; schema: undefined; columns: { ...; }; dialect: "pg"; }>, ... 4 more ..., never>', gave the following error.
Object literal may only specify known properties, and 'offerId' does not exist in type '{ skillId: string | SQL<unknown> | Placeholder<string, any>; offerId: string | SQL<unknown> | Placeholder<string, any>; }[]'.
No overload matches this call.
Overload 1 of 2, '(value: { skillId: string | SQL<unknown> | Placeholder<string, any>; offerId: string | SQL<unknown> | Placeholder<string, any>; }): PgInsertBase<PgTableWithColumns<{ name: "offer_skills"; schema: undefined; columns: { ...; }; dialect: "pg"; }>, ... 4 more ..., never>', gave the following error.
Object literal may only specify known properties, and 'mandatory' does not exist in type '{ skillId: string | SQL<unknown> | Placeholder<string, any>; offerId: string | SQL<unknown> | Placeholder<string, any>; }'.
Overload 2 of 2, '(values: { skillId: string | SQL<unknown> | Placeholder<string, any>; offerId: string | SQL<unknown> | Placeholder<string, any>; }[]): PgInsertBase<PgTableWithColumns<{ name: "offer_skills"; schema: undefined; columns: { ...; }; dialect: "pg"; }>, ... 4 more ..., never>', gave the following error.
Object literal may only specify known properties, and 'offerId' does not exist in type '{ skillId: string | SQL<unknown> | Placeholder<string, any>; offerId: string | SQL<unknown> | Placeholder<string, any>; }[]'.
Both errors are unexplainable to me and after a long time of tinkering around I am out of ideas. I have no idea what the proper type of the drizzle client is so that I can pass it to other functions
3 replies
DTDrizzle Team
Created by uri on 3/4/2025 in #help
How should I refactor my transactions?
This would also work for nested db calls. So for example: Imagine a function A() that calls B() and C(). Both in B() and C() there are database calls. If you annotate A() with @Transactional() you would still have the db calls in B() and C() in the same transaction
10 replies
DTDrizzle Team
Created by uri on 3/4/2025 in #help
How should I refactor my transactions?
@uri
10 replies
DTDrizzle Team
Created by uri on 3/4/2025 in #help
How should I refactor my transactions?
Hey uri, I have figured out a waaaaaay better solution, without you needing to pass any parameter to functions. You would just have to add a @Transactional() Decorator to the root function as of which every database call should be run in a transaction. Are you still looking for a solution?
10 replies
DTDrizzle Team
Created by uri on 3/4/2025 in #help
How should I refactor my transactions?
https://github.com/vkondratiuk482/propagated-transactions Maybe this approach is more to your liking? It would save you adding a new function parameter but its kind of verbose too. But maybe it suits your more than your current solution (which I would prefer)
10 replies
DTDrizzle Team
Created by MUG Knight on 2/25/2025 in #help
Migration not setting DB column to NOT NULL
So what you say is that the generated sql is not correct or applying it will not result in the expected column state?
3 replies
DTDrizzle Team
Created by Titan on 3/1/2025 in #help
Postgres insert returning expecting zero arguments
What version are you using and how does your table schema look like?
2 replies
DTDrizzle Team
Created by iamgengar. on 3/1/2025 in #help
How to make function that takes in a table as parameter with correct types?
This is a bug and was already reported. If you search for a quick fix: Downgrade back to 0.38.
3 replies
DTDrizzle Team
Created by Vâjhâtz on 12/7/2024 in #help
No schema changes, nothing to migrate 😴
Nevermind then, sorry
11 replies
DTDrizzle Team
Created by Vâjhâtz on 12/7/2024 in #help
No schema changes, nothing to migrate 😴
Just saw you are using npx
11 replies
DTDrizzle Team
Created by Vâjhâtz on 12/7/2024 in #help
No schema changes, nothing to migrate 😴
Oh
11 replies
DTDrizzle Team
Created by Vâjhâtz on 12/7/2024 in #help
No schema changes, nothing to migrate 😴
Are you by any chance using bun for this one project? I had the same issue months ago using bun only. Not sure if it is fixed by now. Maybe it is not and you are running into it now too
11 replies
DTDrizzle Team
Created by nu on 12/7/2024 in #help
How to add comment on postgres table columns (and other one-time operations like add trigger)
If I were you I would add this kind of work as a custom migration script. This will ensure that it will only be run when the migrations will be applied aka when the database schema is being set up by drizzle kit. Have a look at https://orm.drizzle.team/docs/kit-custom-migrations for more information on migrations
4 replies
DTDrizzle Team
Created by nu on 12/7/2024 in #help
How to add comment on postgres table columns (and other one-time operations like add trigger)
Hey @nu , I think this question can only be answered by yourself because you call the up function yourself no?
4 replies
DTDrizzle Team
Created by kge on 11/7/2024 in #help
I'm trying using $count, and it giving me fieldAlias missing. What should I do?
Shouldnt it be
historyCount: db.$count(history, eq(history.itemId, item.id))
historyCount: db.$count(history, eq(history.itemId, item.id))
?
6 replies
DTDrizzle Team
Created by François on 10/3/2024 in #help
Anyone also experiencing this issue?
Wish I would have enough time to further dig deeper into their code and actually fix it but life....
8 replies