@steedos/service-objectql 3.0.0-beta.8 → 3.0.0-beta.81
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 +3 -3
- package/package.service.js +33 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-objectql",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.81",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"description": "steedos package",
|
|
14
14
|
"repository": {},
|
|
15
15
|
"license": "MIT",
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "15126b1b1de6e4cb0592f0bc55e1458cac2a1894",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@steedos/objectql": "3.0.0-beta.
|
|
18
|
+
"@steedos/objectql": "3.0.0-beta.81"
|
|
19
19
|
}
|
|
20
20
|
}
|
package/package.service.js
CHANGED
|
@@ -571,8 +571,12 @@ module.exports = {
|
|
|
571
571
|
async handler(ctx) {
|
|
572
572
|
return await this.getPrimarySpaceId()
|
|
573
573
|
}
|
|
574
|
+
},
|
|
575
|
+
getPrimarySpace: {
|
|
576
|
+
async handler(ctx) {
|
|
577
|
+
return await this.getPrimarySpace()
|
|
578
|
+
}
|
|
574
579
|
}
|
|
575
|
-
|
|
576
580
|
},
|
|
577
581
|
|
|
578
582
|
/**
|
|
@@ -653,6 +657,34 @@ module.exports = {
|
|
|
653
657
|
}
|
|
654
658
|
this.primarySpaceId = spaceId
|
|
655
659
|
return this.primarySpaceId
|
|
660
|
+
},
|
|
661
|
+
getPrimarySpace: async function () {
|
|
662
|
+
if(this.primarySpace){
|
|
663
|
+
return this.primarySpace;
|
|
664
|
+
}
|
|
665
|
+
const steedosConfig = objectql.getSteedosConfig();
|
|
666
|
+
let spaceId;
|
|
667
|
+
if (steedosConfig && steedosConfig.tenant && steedosConfig.tenant._id) {
|
|
668
|
+
spaceId = steedosConfig.tenant._id
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
const datasource = objectql.getDataSource('default');
|
|
672
|
+
if (datasource) {
|
|
673
|
+
const adapter = datasource.adapter;
|
|
674
|
+
await adapter.connect()
|
|
675
|
+
const collection = adapter.collection('spaces');
|
|
676
|
+
let space = null;
|
|
677
|
+
if (spaceId) {
|
|
678
|
+
space = await collection.findOne({ _id: spaceId })
|
|
679
|
+
}else{
|
|
680
|
+
space = await collection.findOne()
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
if (space) {
|
|
684
|
+
this.primarySpace = space;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
return this.primarySpace
|
|
656
688
|
}
|
|
657
689
|
},
|
|
658
690
|
|