Skip to content

Commit

Permalink
fix: no undefined in where (#4551)
Browse files Browse the repository at this point in the history
Co-authored-by: Henry Fontanier <[email protected]>
  • Loading branch information
2 people authored and flvndvd committed May 26, 2024
1 parent 9aac5da commit 9d9f194
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions front/lib/resources/membership_resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,16 @@ export class MembershipResource extends BaseResource<MembershipModel> {
(resource) => new MembershipResource(MembershipModel, resource.get())
);

const where: WhereOptions<InferAttributes<MembershipModel>> = {
role: roles,
userId: userIds ? { [Op.in]: userIds } : undefined,
workspaceId: workspace ? workspace.id : undefined,
};
const where: WhereOptions<InferAttributes<MembershipModel>> = {};
if (roles) {
where.role = roles;
}
if (userIds) {
where.userId = userIds;
}
if (workspace) {
where.workspaceId = workspace.id;
}

if (!workspace && !userIds?.length) {
throw new Error("At least one of workspace or userIds must be provided.");
Expand Down

0 comments on commit 9d9f194

Please sign in to comment.