Skip to content

Commit abf40ce

Browse files
committed
fix: use db distinct to refact tags retreiving
1 parent 0cd63b8 commit abf40ce

File tree

1 file changed

+4
-13
lines changed
  • packages/system-server/src/router/function

1 file changed

+4
-13
lines changed

packages/system-server/src/router/function/get.ts

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @Author: Maslow<[email protected]>
33
* @Date: 2021-08-30 16:51:19
4-
* @LastEditTime: 2021-09-28 17:21:46
4+
* @LastEditTime: 2021-09-29 12:12:36
55
* @Description:
66
*/
77

@@ -119,21 +119,12 @@ export async function handleGetAllFunctionTags(req: Request, res: Response) {
119119
const db = DatabaseAgent.sys_accessor.db
120120

121121
const docs = await db.collection<FunctionStruct>(Constants.cn.functions)
122-
.find({
123-
tags: { $exists: true, $ne: [] },
122+
.distinct('tags', {
124123
appid: app.appid
125-
}, {
126-
projection: { tags: 1 }
124+
127125
})
128-
.toArray()
129126

130-
const all_tags = []
131-
for (const doc of docs) {
132-
const tags = doc.tags
133-
all_tags.push(...tags)
134-
}
135-
const rets = Array.from(new Set(all_tags))
136127
return res.send({
137-
data: rets
128+
data: docs
138129
})
139130
}

0 commit comments

Comments
 (0)