yaml-admin-api 0.0.30 → 0.0.32
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
|
@@ -594,19 +594,47 @@ const makeApiGenerateFields = async (db, entity_name, yml_entity, yml, options,
|
|
|
594
594
|
limit = limit || 1000
|
|
595
595
|
|
|
596
596
|
let match_from_list = data_list.map(m=>matchPathInObject(m, match_from))
|
|
597
|
-
|
|
598
597
|
match_from_list = match_from_list.filter(m=>m)
|
|
599
598
|
const f = { [match]: {$in:match_from_list} }
|
|
600
599
|
const projection = {[match]:1}
|
|
601
600
|
|
|
601
|
+
const aggregate = [
|
|
602
|
+
{ $match: { [match]: {$in:match_from_list} } },
|
|
603
|
+
]
|
|
604
|
+
|
|
602
605
|
if(field)
|
|
603
606
|
projection[field] = 1
|
|
604
|
-
else
|
|
607
|
+
else {
|
|
605
608
|
fields.map(m=>{
|
|
606
609
|
projection[m.name] = 1
|
|
607
610
|
})
|
|
608
611
|
|
|
609
|
-
|
|
612
|
+
fields.map(m=>{
|
|
613
|
+
if(m.type == 'reference') {
|
|
614
|
+
let project = { _id: 0 }
|
|
615
|
+
m.fields.map(f=>{
|
|
616
|
+
project[f.name] = 1
|
|
617
|
+
})
|
|
618
|
+
|
|
619
|
+
aggregate.push({ $lookup: {
|
|
620
|
+
from: m.reference_entity,
|
|
621
|
+
let: { local_key: '$'+m.reference_from },
|
|
622
|
+
pipeline: [
|
|
623
|
+
{ $match: { $expr: { $eq: ["$"+m.reference_match, "$$local_key"] } } },
|
|
624
|
+
{ $project: project }
|
|
625
|
+
],
|
|
626
|
+
as: m.name
|
|
627
|
+
} })
|
|
628
|
+
if(m.single)
|
|
629
|
+
aggregate.push({ $unwind: `$${m.name}` })
|
|
630
|
+
}
|
|
631
|
+
})
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
const result = await db.collection(entity)
|
|
635
|
+
.aggregate(aggregate)
|
|
636
|
+
.project(projection)
|
|
637
|
+
.toArray()
|
|
610
638
|
data_list.map(m=>{
|
|
611
639
|
let found = result.filter(f=>matchPathInObject(f, match) === matchPathInObject(m, match_from))
|
|
612
640
|
if(single) {
|
package/src/login/auth.js
CHANGED
|
@@ -79,7 +79,7 @@ const withConfig = (config) => {
|
|
|
79
79
|
next);
|
|
80
80
|
}
|
|
81
81
|
else {
|
|
82
|
-
|
|
82
|
+
const memberProjection = { projection: { _id: false, name: true, email: true, password: true, super: true, id: true } };
|
|
83
83
|
if (type === 'email') {
|
|
84
84
|
memberProjection['password'] = true;
|
|
85
85
|
let member = await db.collection('admin').findOne({ email: email }, memberProjection)
|