Skip to content

Conversation

@matheusbsilva137
Copy link
Contributor

Proposed changes (including videos or screenshots)

  • Add support for queries (within the query parameter);
  • Add support to pagination (offset and count) when an user doesn't have the permission to get all rooms.

Issue(s)

Task - ClickUp

Steps to test or reproduce

Example input (using cURL):

curl -G 'http://localhost:3000/api/v1/teams.listRooms?teamId=60538ebf22ff2e119e52f086' \
  --data-urlencode 'query={"ts":{"$gt":{"$date":"2021-03-26T19:46:38.143Z"}}}' \
  -H 'X-Auth-Token: c3rQDH_Fpa7JHSgUrWvlpxwIi1AAu4qTnfAF4SFgWkB' \
  -H 'X-User-Id: dizcH9Edm8hC7ziDX' \
  -H 'Content-Type: application/json'

Further comments

}
if (getAllRooms) {
const teamRoomsCursor = this.RoomsModel.findByTeamId(teamId, { skip, limit });
const teamRoomsCursor = this.RoomsModel.findByTeamId(teamId, { skip, limit }, query as FilterQuery<IRoom>);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to type cast as FilterQuery =) typescript can already infer that from the param ;)

Suggested change
const teamRoomsCursor = this.RoomsModel.findByTeamId(teamId, { skip, limit }, query as FilterQuery<IRoom>);
const teamRoomsCursor = this.RoomsModel.findByTeamId(teamId, { skip, limit }, query);

};
}
const teamRooms = await this.RoomsModel.findByTeamId(teamId, { projection: { _id: 1, t: 1 } }).toArray();
const teamRooms = await this.RoomsModel.findByTeamId(teamId, { skip, limit, projection: { _id: 1, t: 1 } }, query as FilterQuery<IRoom>).toArray();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const teamRooms = await this.RoomsModel.findByTeamId(teamId, { skip, limit, projection: { _id: 1, t: 1 } }, query as FilterQuery<IRoom>).toArray();
const teamRooms = await this.RoomsModel.findByTeamId(teamId, { skip, limit, projection: { _id: 1, t: 1 } }, query).toArray();

@sampaiodiego sampaiodiego changed the title [IMPROVE] teams.listRooms endpoint doesn't support queries Regression: Add support to filter on teams.listRooms endpoint Mar 29, 2021
@sampaiodiego sampaiodiego merged commit b10da0b into develop Mar 29, 2021
@sampaiodiego sampaiodiego deleted the teams-back-list-rooms-queries branch March 29, 2021 17:48
@sampaiodiego sampaiodiego mentioned this pull request Apr 3, 2021
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants