TGTGamer
TGTGamer
Explore posts from servers
DTDrizzle Team
Created by TGTGamer on 10/22/2024 in #help
Where based on relationships?
I'm trying to query the database for a specific values which fit a filter based on relationships. Is this possible?
const result = yield* Effect.tryPromise(
() => db.query.productUniqueId.findMany(
{
// ...options,
where:
(
productUniqueId,
{ and, eq }
) => (
and(
eq( productUniqueId.type, type ),
eq( productUniqueId.product.outlets.outlet.id, outletId),
)
),
with: {
product: {
columns: {},
with: {
outlets: {
columns: {},
with: {
outlet: {
columns: {
id: true,
name: true
}
}
}
}
}
}
}
}
)
)
const result = yield* Effect.tryPromise(
() => db.query.productUniqueId.findMany(
{
// ...options,
where:
(
productUniqueId,
{ and, eq }
) => (
and(
eq( productUniqueId.type, type ),
eq( productUniqueId.product.outlets.outlet.id, outletId),
)
),
with: {
product: {
columns: {},
with: {
outlets: {
columns: {},
with: {
outlet: {
columns: {
id: true,
name: true
}
}
}
}
}
}
}
}
)
)
In the above example I got the TS2551: Property product does not exist on type - so I switched to filtering after getting the data from the database, but wanted to see if there was a way to handle this in the query
1 replies
DTDrizzle Team
Created by TGTGamer on 10/7/2024 in #help
Many to Many Query With
Pretty simply question. Many to Many relationships have "helper" tables. These simply relate the two tables together. Is there a way to ignore the helper tables in the query output? My current attempts just end up with: TS2353: Object literal may only specify known properties....
const result = yield* Effect.tryPromise(
() => db.query.pos.findFirst( {
where: (
pos,
{ eq }
) => (
eq( pos.id, id )
),
with: {
outlets: {
with: {
outlet: {
with: {
products: {
with: {
product: true
}
}
}
}
}
}
}
}
} )
)
const result = yield* Effect.tryPromise(
() => db.query.pos.findFirst( {
where: (
pos,
{ eq }
) => (
eq( pos.id, id )
),
with: {
outlets: {
with: {
outlet: {
with: {
products: {
with: {
product: true
}
}
}
}
}
}
}
}
} )
)
1 replies
EEventiva
Created by TGTGamer on 1/5/2024 in #support
Testing Thread
To test that answer overflow is configured correctly
2 replies
SIASapphire - Imagine a framework
Created by TGTGamer on 12/10/2023 in #sapphire-support
Bit.dev API Plugin not working
Ok, so I'm having a issue with my bot and I'm really struggling to figure out where I've gone wrong. So I started with the template using sapphire new and chose the typescript variation and full template, which has the api's. I then converted this bot template to work with Bit.dev as can be found here: https://bit.cloud/eventiva/bots/discord/helper/~code/helper.ts https://bit.cloud/eventiva/bots/discord/helper/~code/helper.app-root.ts It works fine to run the command, but it doesn't seem to be working for the plugins, and I'm really unsure what I should be doing differently. I'm importing the import '@sapphire/plugin-api/register'; and the server is listening true when I do a console.log(client.server.server.listening); Yet when I go to localhost:4000 or 127.0.0.1:4000 I can't seem to connect and I'm really dumbfounded. Any chance one of you can see something stupid I'm missing?
26 replies