yaml-admin-api 0.0.41 → 0.0.42
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
|
@@ -210,8 +210,14 @@ const generateCrud = async ({ app, db, entity_name, yml_entity, yml, options })
|
|
|
210
210
|
}
|
|
211
211
|
})
|
|
212
212
|
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
if(req.query['id']) {
|
|
214
|
+
let array = req.query['id']
|
|
215
|
+
if(Array.isArray(array)) {
|
|
216
|
+
f[key_field.name] = { $in: array.map(v => parseKey(v)) }
|
|
217
|
+
} else {
|
|
218
|
+
f[key_field.name] = parseKey(array)
|
|
219
|
+
}
|
|
220
|
+
}
|
|
215
221
|
|
|
216
222
|
var name = req.query.name;
|
|
217
223
|
if (name == null && req.query.q)
|
|
@@ -237,6 +243,7 @@ const generateCrud = async ({ app, db, entity_name, yml_entity, yml, options })
|
|
|
237
243
|
console.log('list', entity_name, 'found', count)
|
|
238
244
|
|
|
239
245
|
await addInfo(db, list)
|
|
246
|
+
options?.listener?.entityListed?.(db, entity_name, list)
|
|
240
247
|
|
|
241
248
|
res.header('X-Total-Count', count);
|
|
242
249
|
res.json(list);
|
|
@@ -370,6 +377,9 @@ const generateCrud = async ({ app, db, entity_name, yml_entity, yml, options })
|
|
|
370
377
|
m.id = getKeyFromEntity(m)
|
|
371
378
|
await addInfo(db, [m])
|
|
372
379
|
|
|
380
|
+
if(yml.debug)
|
|
381
|
+
console.log('show', entity_name, m)
|
|
382
|
+
|
|
373
383
|
res.json(m);
|
|
374
384
|
}))
|
|
375
385
|
|
|
@@ -601,7 +611,6 @@ const makeApiGenerateFields = async (db, entity_name, yml_entity, yml, options,
|
|
|
601
611
|
|
|
602
612
|
let match_from_list = data_list.map(m=>matchPathInObject(m, match_from))
|
|
603
613
|
match_from_list = match_from_list.filter(m=>m)
|
|
604
|
-
const f = { [match]: {$in:match_from_list} }
|
|
605
614
|
const projection = {[match]:1}
|
|
606
615
|
|
|
607
616
|
const aggregate = [
|
|
@@ -610,7 +619,7 @@ const makeApiGenerateFields = async (db, entity_name, yml_entity, yml, options,
|
|
|
610
619
|
|
|
611
620
|
if(field)
|
|
612
621
|
projection[field] = 1
|
|
613
|
-
else {
|
|
622
|
+
else if(fields){
|
|
614
623
|
fields.map(m=>{
|
|
615
624
|
projection[m.name] = 1
|
|
616
625
|
})
|
|
@@ -618,9 +627,13 @@ const makeApiGenerateFields = async (db, entity_name, yml_entity, yml, options,
|
|
|
618
627
|
fields.map(m=>{
|
|
619
628
|
if(m.type == 'reference') {
|
|
620
629
|
let project = { _id: 0 }
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
630
|
+
|
|
631
|
+
if(m.field)
|
|
632
|
+
project[m.field] = 1
|
|
633
|
+
else
|
|
634
|
+
m.fields.map(f=>{
|
|
635
|
+
project[f.name] = 1
|
|
636
|
+
})
|
|
624
637
|
|
|
625
638
|
aggregate.push({ $lookup: {
|
|
626
639
|
from: m.reference_entity,
|
|
@@ -633,6 +646,9 @@ const makeApiGenerateFields = async (db, entity_name, yml_entity, yml, options,
|
|
|
633
646
|
} })
|
|
634
647
|
if(m.single)
|
|
635
648
|
aggregate.push({ $unwind: `$${m.name}` })
|
|
649
|
+
|
|
650
|
+
if(m.field)
|
|
651
|
+
aggregate.push({ $addFields: { [m.field]: `$${m.name}.${m.field}` } })
|
|
636
652
|
}
|
|
637
653
|
})
|
|
638
654
|
}
|