Relational queries: many-to-many

How to exclude xId fields from findFirst | findMany method or i just need to use "Magical sql operator" :D. And can I get rid of the usersToStudios field?
{
name: string;
id: number;
createdAt: Date;
description: string | null;
ownerId: number;
user: {
name: string;
email: string;
password: string;
id: number;
createdAt: Date;
}[];
}
{
name: string;
id: number;
createdAt: Date;
description: string | null;
ownerId: number;
user: {
name: string;
email: string;
password: string;
id: number;
createdAt: Date;
}[];
}
9 Replies
Pillow
PillowOP16mo ago
NinjaBunny
NinjaBunny16mo ago
you would have to check yourself, but you can specify the columns that get returned now if you don’t want any columns from the usesToStudio table correct me if i’m wrong, but you may be able to put an empty object there so it returns no columns lmk if what is said didn’t make sense haha i just woke up
Pillow
PillowOP16mo ago
i did it as described in the doc.
NinjaBunny
NinjaBunny16mo ago
sorry what part of this result are you trying to remove?
Pillow
PillowOP16mo ago
I'd my results to look like
const res: {
id: number;
name: string;
verified: boolean;
invitedBy: number | null;
fullName: string;
group: {
id: number;
name: string;
description: string | null;
}[];
}[];
const res: {
id: number;
name: string;
verified: boolean;
invitedBy: number | null;
fullName: string;
group: {
id: number;
name: string;
description: string | null;
}[];
}[];
NinjaBunny
NinjaBunny16mo ago
oh okay I see so you're just trying to remove the object usersToGroups and place that result inside of the object off the top of my head I don't know if there is a way to do it using relational queries that would be a better question for the devs however I know you can do this if you were to create the query yourself as you can define the shape that gets returned in the select() part of the query
Pillow
PillowOP16mo ago
Pillow
PillowOP16mo ago
😭
NinjaBunny
NinjaBunny16mo ago
isn't that what you wanted?
Want results from more Discord servers?
Add your server