@steedos/service-rest 3.0.0-beta.8 → 3.0.0-beta.80
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 -2
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.80",
|
|
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.80",
|
|
20
|
+
"@steedos/service-object-mixin": "3.0.0-beta.80",
|
|
21
21
|
"lodash": "^4.17.21"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "32e451dcb9225c8968200081644d507bb67ebe17"
|
|
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
|
|
@@ -534,7 +534,6 @@ module.exports = {
|
|
|
534
534
|
const userSession = ctx.meta.user;
|
|
535
535
|
const query = {}
|
|
536
536
|
if (fields) {
|
|
537
|
-
console.log(`fields:`, fields)
|
|
538
537
|
query.fields = JSON.parse(fields)
|
|
539
538
|
}
|
|
540
539
|
const doc = await this.findOne(objectName, id, query, userSession)
|
|
@@ -788,6 +787,50 @@ module.exports = {
|
|
|
788
787
|
}
|
|
789
788
|
}
|
|
790
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
|
+
}
|
|
791
834
|
},
|
|
792
835
|
|
|
793
836
|
/**
|