Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
🐛 Return created membership with group
Browse files Browse the repository at this point in the history
  • Loading branch information
AnandChowdhary committed Nov 16, 2020
1 parent 2adfc21 commit 69a88ce
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/modules/groups/groups.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ import { GroupsService } from './groups.service';
imports: [PrismaModule],
controllers: [GroupController],
providers: [GroupsService],
exports: [GroupsService],
})
export class GroupsModule {}
3 changes: 2 additions & 1 deletion src/modules/groups/groups.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class GroupsService {
async createGroup(
userId: number,
data: Omit<Omit<groupsCreateInput, 'group'>, 'user'>,
): Promise<groups> {
) {
let initials = data.name.trim().substr(0, 2).toUpperCase();
if (data.name.includes(' '))
initials = data.name
Expand All @@ -33,6 +33,7 @@ export class GroupsService {
luminosity: 'light',
})}&color=000000`;
return this.prisma.groups.create({
include: { memberships: { include: { group: true } } },
data: {
...data,
memberships: {
Expand Down
3 changes: 2 additions & 1 deletion src/modules/memberships/memberships.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ export class MembershipsService {
}

async createUserMembership(userId: number, data: groupsCreateInput) {
return this.groupsService.createGroup(userId, data);
const created = await this.groupsService.createGroup(userId, data);
return created.memberships[0];
}

async createGroupMembership(
Expand Down

0 comments on commit 69a88ce

Please sign in to comment.