Skip to content

Commit de95cd3

Browse files
committed
Add a count of members to the Paginated Teams table
1 parent 7c27245 commit de95cd3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/models/team.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,11 @@ async function paginatedList(options = {}) {
200200
const { bbox, osmId, organizationId, page, includePrivate } = options
201201
const st = knexPostgis(db)
202202

203-
let query = db('team').select(...teamAttributes, st.asGeoJSON('location'))
203+
let query = db('team').select(
204+
...teamAttributes,
205+
st.asGeoJSON('location'),
206+
db('member').count().whereRaw('team.id = member.team_id').as('members')
207+
)
204208

205209
if (!includePrivate) {
206210
query.where('privacy', 'public')

0 commit comments

Comments
 (0)