xamarot
xamarot
DTDrizzle Team
Created by xamarot on 11/13/2023 in #help
Omit fields on "$inferSelect"?
Ah thanks
3 replies
DTDrizzle Team
Created by xamarot on 8/21/2023 in #help
How to use "onConflictDoUpdate" with composite key?
thank you
10 replies
DTDrizzle Team
Created by Chiko on 8/20/2023 in #help
Error when pushing to the db
Which was?
7 replies
DTDrizzle Team
Created by Chiko on 8/20/2023 in #help
Error when pushing to the db
in your guilds table you reference twitch table's primary key as a serial, but it should probably be an integer. or change both to serial, preferrably.
7 replies
DTDrizzle Team
Created by xamarot on 8/17/2023 in #help
Invert a boolean easily?
Thank you
4 replies
DTDrizzle Team
Created by xamarot on 8/9/2023 in #help
Get the latest message from each user in a table
I restructured my database a bit since it was a bitch to work with the way I wanted it to, but using relational queries I finally got it working. Thank you!
16 replies
DTDrizzle Team
Created by xamarot on 8/9/2023 in #help
Get the latest message from each user in a table
I will look at it once I get a chance. Thank you!
16 replies
DTDrizzle Team
Created by xamarot on 8/9/2023 in #help
Get the latest message from each user in a table
Hmm, not f familiar with that one. I will check out the docs.
16 replies
DTDrizzle Team
Created by xamarot on 8/9/2023 in #help
Get the latest message from each user in a table
Yeah i tried using relational queries as well but couldn't figure it out
16 replies
DTDrizzle Team
Created by xamarot on 8/9/2023 in #help
Get the latest message from each user in a table
Users with one message each, ideally, but either way really
16 replies
DTDrizzle Team
Created by xamarot on 8/9/2023 in #help
Get the latest message from each user in a table
Right now my query is
const m = (await db
.select({
sender: auth_user.username,
content: messages.content,
sentAt: messages.sentAt
})
.from(messages)
.leftJoin(auth_user, eq(auth_user.id, messages.sender))
.where(
or(
eq(messages.recipient, user.userId),
eq(messages.sender, user.userId)
)
).orderBy(messages.sentAt));
const m = (await db
.select({
sender: auth_user.username,
content: messages.content,
sentAt: messages.sentAt
})
.from(messages)
.leftJoin(auth_user, eq(auth_user.id, messages.sender))
.where(
or(
eq(messages.recipient, user.userId),
eq(messages.sender, user.userId)
)
).orderBy(messages.sentAt));
but this gives me all messages, like:
{
sender: 'test2',
content: "Hello",
sentAt: 2023-08-10T07:07:20.000Z
},
{
sender: 'test',
content: 'Hola',
sentAt: 2023-08-10T10:33:00.000Z
},
... // more messages omitted
{
sender: 'test2',
content: "Hello",
sentAt: 2023-08-10T07:07:20.000Z
},
{
sender: 'test',
content: 'Hola',
sentAt: 2023-08-10T10:33:00.000Z
},
... // more messages omitted
it seems to me like I should add some sort of "distinct" filter for the "sender"?
16 replies
DTDrizzle Team
Created by azn4lifee on 8/8/2023 in #help
How can I declare a relationship with a SELECT statement?
Why do you have to put it as relations?
8 replies
DTDrizzle Team
Created by azn4lifee on 8/8/2023 in #help
How can I declare a relationship with a SELECT statement?
I don't think you can do that. I think what you want is actually a View
8 replies
DTDrizzle Team
Created by Sebastián on 7/29/2023 in #help
Are relational queries supported on mysql?
aight, just ask if theres anything else. good luck!
36 replies
DTDrizzle Team
Created by Sebastián on 7/29/2023 in #help
Are relational queries supported on mysql?
all costumes for your gender?
36 replies
DTDrizzle Team
Created by Sebastián on 7/29/2023 in #help
Are relational queries supported on mysql?
hm i don't think you want to use "with" here. Since "gender" can not be null, "with" does not make sense since it will always be true, and I'm not sure but I don't think it works for "one"-relations. what data is it you want to retrieve?
36 replies
DTDrizzle Team
Created by Sebastián on 7/29/2023 in #help
Are relational queries supported on mysql?
because it looks to me like "myGender" is basically another variable? if thats the case you could do
const result = await db.query.costume.findMany({
where: and(eq(costume.id, costumeId), eq(costume.gender, myGender))
})
const result = await db.query.costume.findMany({
where: and(eq(costume.id, costumeId), eq(costume.gender, myGender))
})
36 replies
DTDrizzle Team
Created by Sebastián on 7/29/2023 in #help
Are relational queries supported on mysql?
from docs
const posts = await db.query.posts.findMany({
with: {
comments: true,
},
});
const posts = await db.query.posts.findMany({
with: {
comments: true,
},
});
how does your schema structure look? what is it you want to retrieve?
36 replies
DTDrizzle Team
Created by Sebastián on 7/29/2023 in #help
Are relational queries supported on mysql?
such as a post having comments, or such things
36 replies
DTDrizzle Team
Created by Sebastián on 7/29/2023 in #help
Are relational queries supported on mysql?
i am not entirely sure but i think "with" is only used for related data
36 replies