@opra/mongodb 1.19.7 → 1.21.0
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.
|
@@ -13,15 +13,15 @@ var MongoAdapter;
|
|
|
13
13
|
MongoAdapter.prepareProjection = prepare_projection_js_1.default;
|
|
14
14
|
MongoAdapter.prepareSort = prepare_sort_js_1.default;
|
|
15
15
|
async function parseRequest(context) {
|
|
16
|
-
if (context.
|
|
16
|
+
if (context.transport !== 'http') {
|
|
17
17
|
throw new TypeError('MongoAdapter can parse only HttpContext');
|
|
18
18
|
}
|
|
19
19
|
const ctx = context;
|
|
20
|
-
const {
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
const controller =
|
|
24
|
-
switch (
|
|
20
|
+
const { __oprDef } = ctx;
|
|
21
|
+
if (__oprDef?.composition?.startsWith('Entity.') &&
|
|
22
|
+
__oprDef.compositionOptions?.type) {
|
|
23
|
+
const controller = __oprDef.owner;
|
|
24
|
+
switch (__oprDef.composition) {
|
|
25
25
|
case 'Entity.Create': {
|
|
26
26
|
const data = await ctx.getBody();
|
|
27
27
|
const options = {
|
|
@@ -34,7 +34,7 @@ var MongoAdapter;
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
case 'Entity.Delete': {
|
|
37
|
-
const keyParam =
|
|
37
|
+
const keyParam = __oprDef.parameters.find(p => p.keyParam) ||
|
|
38
38
|
controller.parameters.find(p => p.keyParam);
|
|
39
39
|
const key = keyParam && ctx.pathParams[String(keyParam.name)];
|
|
40
40
|
const options = {
|
|
@@ -56,17 +56,16 @@ var MongoAdapter;
|
|
|
56
56
|
const options = {
|
|
57
57
|
filter: ctx.queryParams.filter,
|
|
58
58
|
projection: ctx.queryParams.projection ||
|
|
59
|
-
|
|
59
|
+
__oprDef.compositionOptions.defaultProjection,
|
|
60
60
|
count: ctx.queryParams.count,
|
|
61
|
-
limit: ctx.queryParams.limit ||
|
|
62
|
-
operation.compositionOptions.defaultLimit,
|
|
61
|
+
limit: ctx.queryParams.limit || __oprDef.compositionOptions.defaultLimit,
|
|
63
62
|
skip: ctx.queryParams.skip,
|
|
64
|
-
sort: ctx.queryParams.sort ||
|
|
63
|
+
sort: ctx.queryParams.sort || __oprDef.compositionOptions.defaultSort,
|
|
65
64
|
};
|
|
66
65
|
return { method: 'findMany', options };
|
|
67
66
|
}
|
|
68
67
|
case 'Entity.Get': {
|
|
69
|
-
const keyParam =
|
|
68
|
+
const keyParam = __oprDef.parameters.find(p => p.keyParam) ||
|
|
70
69
|
controller.parameters.find(p => p.keyParam);
|
|
71
70
|
const key = keyParam && ctx.pathParams[String(keyParam.name)];
|
|
72
71
|
const options = {
|
|
@@ -77,7 +76,7 @@ var MongoAdapter;
|
|
|
77
76
|
}
|
|
78
77
|
case 'Entity.Replace': {
|
|
79
78
|
const data = await ctx.getBody();
|
|
80
|
-
const keyParam =
|
|
79
|
+
const keyParam = __oprDef.parameters.find(p => p.keyParam) ||
|
|
81
80
|
controller.parameters.find(p => p.keyParam);
|
|
82
81
|
const key = keyParam && ctx.pathParams[String(keyParam.name)];
|
|
83
82
|
const options = {
|
|
@@ -93,7 +92,7 @@ var MongoAdapter;
|
|
|
93
92
|
}
|
|
94
93
|
case 'Entity.Update': {
|
|
95
94
|
const data = await ctx.getBody();
|
|
96
|
-
const keyParam =
|
|
95
|
+
const keyParam = __oprDef.parameters.find(p => p.keyParam) ||
|
|
97
96
|
controller.parameters.find(p => p.keyParam);
|
|
98
97
|
const key = keyParam && ctx.pathParams[String(keyParam.name)];
|
|
99
98
|
const options = {
|
|
@@ -94,7 +94,7 @@ class MongoService extends core_1.ServiceBase {
|
|
|
94
94
|
if (this._dataType && this._dataTypeScope !== this.scope)
|
|
95
95
|
this._dataType = undefined;
|
|
96
96
|
if (!this._dataType)
|
|
97
|
-
this._dataType = this.context.
|
|
97
|
+
this._dataType = this.context.__docNode.getComplexType(this._dataType_);
|
|
98
98
|
this._dataTypeScope = this.scope;
|
|
99
99
|
return this._dataType;
|
|
100
100
|
}
|
|
@@ -9,15 +9,15 @@ export var MongoAdapter;
|
|
|
9
9
|
MongoAdapter.prepareProjection = _prepareProjection;
|
|
10
10
|
MongoAdapter.prepareSort = _prepareSort;
|
|
11
11
|
async function parseRequest(context) {
|
|
12
|
-
if (context.
|
|
12
|
+
if (context.transport !== 'http') {
|
|
13
13
|
throw new TypeError('MongoAdapter can parse only HttpContext');
|
|
14
14
|
}
|
|
15
15
|
const ctx = context;
|
|
16
|
-
const {
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
const controller =
|
|
20
|
-
switch (
|
|
16
|
+
const { __oprDef } = ctx;
|
|
17
|
+
if (__oprDef?.composition?.startsWith('Entity.') &&
|
|
18
|
+
__oprDef.compositionOptions?.type) {
|
|
19
|
+
const controller = __oprDef.owner;
|
|
20
|
+
switch (__oprDef.composition) {
|
|
21
21
|
case 'Entity.Create': {
|
|
22
22
|
const data = await ctx.getBody();
|
|
23
23
|
const options = {
|
|
@@ -30,7 +30,7 @@ export var MongoAdapter;
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
case 'Entity.Delete': {
|
|
33
|
-
const keyParam =
|
|
33
|
+
const keyParam = __oprDef.parameters.find(p => p.keyParam) ||
|
|
34
34
|
controller.parameters.find(p => p.keyParam);
|
|
35
35
|
const key = keyParam && ctx.pathParams[String(keyParam.name)];
|
|
36
36
|
const options = {
|
|
@@ -52,17 +52,16 @@ export var MongoAdapter;
|
|
|
52
52
|
const options = {
|
|
53
53
|
filter: ctx.queryParams.filter,
|
|
54
54
|
projection: ctx.queryParams.projection ||
|
|
55
|
-
|
|
55
|
+
__oprDef.compositionOptions.defaultProjection,
|
|
56
56
|
count: ctx.queryParams.count,
|
|
57
|
-
limit: ctx.queryParams.limit ||
|
|
58
|
-
operation.compositionOptions.defaultLimit,
|
|
57
|
+
limit: ctx.queryParams.limit || __oprDef.compositionOptions.defaultLimit,
|
|
59
58
|
skip: ctx.queryParams.skip,
|
|
60
|
-
sort: ctx.queryParams.sort ||
|
|
59
|
+
sort: ctx.queryParams.sort || __oprDef.compositionOptions.defaultSort,
|
|
61
60
|
};
|
|
62
61
|
return { method: 'findMany', options };
|
|
63
62
|
}
|
|
64
63
|
case 'Entity.Get': {
|
|
65
|
-
const keyParam =
|
|
64
|
+
const keyParam = __oprDef.parameters.find(p => p.keyParam) ||
|
|
66
65
|
controller.parameters.find(p => p.keyParam);
|
|
67
66
|
const key = keyParam && ctx.pathParams[String(keyParam.name)];
|
|
68
67
|
const options = {
|
|
@@ -73,7 +72,7 @@ export var MongoAdapter;
|
|
|
73
72
|
}
|
|
74
73
|
case 'Entity.Replace': {
|
|
75
74
|
const data = await ctx.getBody();
|
|
76
|
-
const keyParam =
|
|
75
|
+
const keyParam = __oprDef.parameters.find(p => p.keyParam) ||
|
|
77
76
|
controller.parameters.find(p => p.keyParam);
|
|
78
77
|
const key = keyParam && ctx.pathParams[String(keyParam.name)];
|
|
79
78
|
const options = {
|
|
@@ -89,7 +88,7 @@ export var MongoAdapter;
|
|
|
89
88
|
}
|
|
90
89
|
case 'Entity.Update': {
|
|
91
90
|
const data = await ctx.getBody();
|
|
92
|
-
const keyParam =
|
|
91
|
+
const keyParam = __oprDef.parameters.find(p => p.keyParam) ||
|
|
93
92
|
controller.parameters.find(p => p.keyParam);
|
|
94
93
|
const key = keyParam && ctx.pathParams[String(keyParam.name)];
|
|
95
94
|
const options = {
|
|
@@ -91,7 +91,7 @@ export class MongoService extends ServiceBase {
|
|
|
91
91
|
if (this._dataType && this._dataTypeScope !== this.scope)
|
|
92
92
|
this._dataType = undefined;
|
|
93
93
|
if (!this._dataType)
|
|
94
|
-
this._dataType = this.context.
|
|
94
|
+
this._dataType = this.context.__docNode.getComplexType(this._dataType_);
|
|
95
95
|
this._dataTypeScope = this.scope;
|
|
96
96
|
return this._dataType;
|
|
97
97
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/mongodb",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.0",
|
|
4
4
|
"description": "Opra MongoDB adapter package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"valgen": "^5.18.2"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@opra/common": "^1.
|
|
14
|
-
"@opra/core": "^1.
|
|
15
|
-
"@opra/http": "^1.
|
|
16
|
-
"mongodb": "^
|
|
13
|
+
"@opra/common": "^1.21.0",
|
|
14
|
+
"@opra/core": "^1.21.0",
|
|
15
|
+
"@opra/http": "^1.21.0",
|
|
16
|
+
"mongodb": "^7.0.0"
|
|
17
17
|
},
|
|
18
18
|
"type": "module",
|
|
19
19
|
"exports": {
|