energistic
energistic
DTDrizzle Team
Created by energistic on 12/19/2023 in #help
Filter on relations based upon a WITH
I'd like to filter based upon a table that's in the with clause.
db.query.myTable.findMany({
where: inArray(otherTable.id, [1,2]),
with: {
otherTable: true,
}
})
db.query.myTable.findMany({
where: inArray(otherTable.id, [1,2]),
with: {
otherTable: true,
}
})
2 replies
DTDrizzle Team
Created by energistic on 12/10/2023 in #help
Shortcut for .returning()
Is there a shortcut for .returning() where there's only one table I'm selecting from? I write:
.returning({
id: userSchema.id,
email: userSchema.email,
username: userSchema.username,
name: userSchema.name,
})
.returning({
id: userSchema.id,
email: userSchema.email,
username: userSchema.username,
name: userSchema.name,
})
would prefer to write:
.returning({ id, email, username, name})
// or
.returning([ 'id', 'email', 'username', 'name'])
.returning({ id, email, username, name})
// or
.returning([ 'id', 'email', 'username', 'name'])
3 replies
DTDrizzle Team
Created by energistic on 11/28/2023 in #help
Implicit many-to-many schema
I would like to define many many-to-many relations with a more terse syntax. I have a database with many many-to-many relations (~30). They are very basic in the sense that the join tables only contain 2 columns - the ids from left and right. Coming from prisma, I could make implicit many-to-many tables with 2 lines of code (and it would generate 2 more lines automatically). Each relation requires about 20 lines of code to express and they all look basically the same. I started trying to write a function to define them more generally but I haven't been able to do with with the amount of Types required. I'm half thinking to define a function that will write out the source code. I totally understand starting with a more powerful and explicit syntax in the evolution of a product. Hoping there are some convenient shortcuts that I may have missed. Thank you
1 replies