yaml-admin-api 0.0.75 → 0.0.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -253,15 +253,12 @@ const generateCrud = async ({ app, db, entity_name, yml_entity, yml, options })
|
|
|
253
253
|
let aggregate = await makeApiGenerateAggregate(db, entity_name, yml_entity, yml, options)
|
|
254
254
|
|
|
255
255
|
if(aggregate?.length > 0) {
|
|
256
|
-
aggregate = [{$match: f}
|
|
257
|
-
|
|
256
|
+
aggregate = [...aggregate, {$match: f}]
|
|
258
257
|
const countResult = await db.collection(entity_name).aggregate([...aggregate, { $count: 'count' }]).toArray()
|
|
259
258
|
count = countResult.length > 0 ? countResult[0].count : 0
|
|
260
259
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
.skip(parseInt(_start))
|
|
264
|
-
.limit(l).toArray()
|
|
260
|
+
aggregate = [...aggregate, { $sort: s }, { $skip: parseInt(_start) }, { $limit: l }]
|
|
261
|
+
list = await db.collection(entity_name).aggregate(aggregate).toArray()
|
|
265
262
|
} else
|
|
266
263
|
{
|
|
267
264
|
count = await db.collection(entity_name).find(f).project(projection).sort(s).count()
|
|
@@ -707,6 +704,12 @@ const makeApiGenerateAggregate = async (db, entity_name, yml_entity, yml, option
|
|
|
707
704
|
{ $match: { $expr: { $eq: ['$' + match, '$$local_key'] } } }
|
|
708
705
|
]
|
|
709
706
|
|
|
707
|
+
// single일 때 max _id로 하나만 선택 ($match 바로 다음에)
|
|
708
|
+
if(single) {
|
|
709
|
+
innerPipeline.push({ $sort: { _id: -1 } })
|
|
710
|
+
innerPipeline.push({ $limit: 1 })
|
|
711
|
+
}
|
|
712
|
+
|
|
710
713
|
// projection 구성
|
|
711
714
|
const projection = { _id: 0, [match]: 1 }
|
|
712
715
|
if(field) {
|
|
@@ -726,8 +729,8 @@ const makeApiGenerateAggregate = async (db, entity_name, yml_entity, yml, option
|
|
|
726
729
|
})
|
|
727
730
|
}
|
|
728
731
|
|
|
729
|
-
// projection을 innerPipeline
|
|
730
|
-
innerPipeline.
|
|
732
|
+
// projection을 innerPipeline에 추가
|
|
733
|
+
innerPipeline.push({ $project: projection })
|
|
731
734
|
|
|
732
735
|
// 기본 $lookup 추가
|
|
733
736
|
aggregate.push({
|