Skip to content

Commit

Permalink
feat: dbm 新增获取集合索引信息;
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Jun 21, 2021
1 parent 20693c7 commit fd1d96c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions http/dbm.http
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ Content-Type: application/json

GET {{base_url}}/admin/collections
Content-Type: application/json
Authorization: Bearer {{token}}

### 获取集合的索引信息

GET {{base_url}}/admin/collection/indexes?collection=functions
Content-Type: application/json
Authorization: Bearer {{token}}
19 changes: 19 additions & 0 deletions src/router/dbm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,23 @@ DbmRouter.get('/collections', async (req, res) => {
const names = colls.map(coll => coll.collectionName)

return res.send(names)
})

DbmRouter.get('/collection/indexes', async (req, res) => {
const requestId = req['requestId']
logger.info(`[${requestId}] get /collection/indexes`)

// 权限验证
const code = await checkPermission(req['auth']?.uid, 'collections.get')
if (code) {
return res.status(code).send()
}

const collectionName = req.query?.collection
if (!collectionName) {
return res.status(404).send('Collection not found')
}

const r = await accessor.db.collection(collectionName as string).indexes()
return res.send(r)
})

0 comments on commit fd1d96c

Please sign in to comment.