@steedos/service-rest 3.0.0-beta.65 → 3.0.0-beta.66
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 +4 -4
- package/package.service.js +45 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-rest",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.66",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"repository": {},
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@steedos/objectql": "3.0.0-beta.
|
|
20
|
-
"@steedos/service-object-mixin": "3.0.0-beta.
|
|
19
|
+
"@steedos/objectql": "3.0.0-beta.66",
|
|
20
|
+
"@steedos/service-object-mixin": "3.0.0-beta.66",
|
|
21
21
|
"lodash": "^4.17.21"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "12ba18394ecbce4f653de5e0625ebed062c091bd"
|
|
24
24
|
}
|
package/package.service.js
CHANGED
|
@@ -13,7 +13,7 @@ const {
|
|
|
13
13
|
} = require('./consts')
|
|
14
14
|
const { translateRecords } = require('./translate');
|
|
15
15
|
const _ = require('lodash')
|
|
16
|
-
const { getObject } = require('@steedos/objectql');
|
|
16
|
+
const { getObject, getObjectConfig } = require('@steedos/objectql');
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* @typedef {import('moleculer').Context} Context Moleculer's Context
|
|
@@ -787,6 +787,50 @@ module.exports = {
|
|
|
787
787
|
}
|
|
788
788
|
}
|
|
789
789
|
},
|
|
790
|
+
names: {
|
|
791
|
+
rest: {
|
|
792
|
+
method: "POST",
|
|
793
|
+
path: "/:objectName/names"
|
|
794
|
+
},
|
|
795
|
+
params: {
|
|
796
|
+
objectName: { type: "string" },
|
|
797
|
+
idKey: { type: "string" },
|
|
798
|
+
ids: { type: 'array', items: "string"}
|
|
799
|
+
},
|
|
800
|
+
async handler(ctx) {
|
|
801
|
+
const params = ctx.params
|
|
802
|
+
const { objectName, ids, idKey = '_id' } = params
|
|
803
|
+
|
|
804
|
+
if(ids.length > 500){
|
|
805
|
+
return {
|
|
806
|
+
"status": 1,
|
|
807
|
+
"msg": "Exceeded maximum ID limit",
|
|
808
|
+
"data": {}
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
const obj = await getObject(objectName);
|
|
813
|
+
|
|
814
|
+
const records = await obj.directFind({
|
|
815
|
+
filters: [idKey, 'in', ids],
|
|
816
|
+
fields: [idKey, obj.NAME_FIELD_KEY || 'name']
|
|
817
|
+
})
|
|
818
|
+
|
|
819
|
+
return {
|
|
820
|
+
"status": REQUEST_SUCCESS_STATUS,
|
|
821
|
+
"msg": "",
|
|
822
|
+
"data": {
|
|
823
|
+
"options": _.map(records, (item)=>{
|
|
824
|
+
return {
|
|
825
|
+
label: item[obj.NAME_FIELD_KEY || 'name'],
|
|
826
|
+
value: item[idKey]
|
|
827
|
+
}
|
|
828
|
+
}),
|
|
829
|
+
"total": records.length
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
790
834
|
},
|
|
791
835
|
|
|
792
836
|
/**
|