[NEW] New/teams back owner#21086
Merged
sampaiodiego merged 8 commits intonew/teams-backfrom Mar 12, 2021
Merged
Conversation
Add unique indexes to team name and team membership Add posibility to assign ownership of team to another user
Create endpoint to fetch all members of a given team
sampaiodiego
requested changes
Mar 12, 2021
server/services/team/service.ts
Outdated
| @@ -1,4 +1,5 @@ | |||
| import { Db } from 'mongodb'; | |||
| import { Meteor } from 'meteor/meteor'; | |||
Member
There was a problem hiding this comment.
we should avoid importing Meteor on services, as doing so we cannot run this service standalone
server/services/team/service.ts
Outdated
| teamId = result.insertedId; | ||
| } catch (e) { | ||
| // TODO should we throw a generic error instead of saying that the team already exists? | ||
| if (e.code === 11000) { |
Member
There was a problem hiding this comment.
not sure what is the best, but we usually check the data before executing the insert instead of trying to guess the error.
server/services/team/service.ts
Outdated
| } | ||
|
|
||
| async members(userId: string, teamId: string): Promise<Array<ITeamMember>> { | ||
| const isMember = await this.TeamMembersModel.findOne({ userId, teamId }); |
Member
There was a problem hiding this comment.
we should have a method on model class to perform this query
server/services/team/service.ts
Outdated
| return []; | ||
| } | ||
|
|
||
| return this.TeamMembersModel.find({ teamId }).toArray(); |
Member
There was a problem hiding this comment.
same as before, we should have a method on model class to perform this query
sampaiodiego
approved these changes
Mar 12, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes (including videos or screenshots)
Issue(s)
Steps to test or reproduce
Further comments