fix(projects): handle non-array collaborators in service to prevent errors
This commit is contained in:
parent
b7d899e66e
commit
1308e9c599
@ -247,6 +247,11 @@ export class ProjectsService {
|
|||||||
.innerJoin(schema.users, eq(schema.projectCollaborators.userId, schema.users.id))
|
.innerJoin(schema.users, eq(schema.projectCollaborators.userId, schema.users.id))
|
||||||
.where(eq(schema.projectCollaborators.projectId, projectId));
|
.where(eq(schema.projectCollaborators.projectId, projectId));
|
||||||
|
|
||||||
|
// Ensure collaborators is an array before mapping
|
||||||
|
if (!Array.isArray(collaborators)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
// Map the results to extract just the user objects
|
// Map the results to extract just the user objects
|
||||||
return collaborators.map(collaborator => collaborator.user);
|
return collaborators.map(collaborator => collaborator.user);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user