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
PillowOP2y ago
NinjaBunny
NinjaBunny2y 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
PillowOP2y ago
i did it as described in the doc.
NinjaBunny
NinjaBunny2y ago
sorry what part of this result are you trying to remove?
Pillow
PillowOP2y 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
NinjaBunny2y 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
PillowOP2y ago
Pillow
PillowOP2y ago
😭
NinjaBunny
NinjaBunny2y ago
isn't that what you wanted?
Want results from more Discord servers?
Add your server