@opra/sqb 0.16.0 → 0.16.2
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/cjs/sqb-collection-resource.js +7 -7
- package/cjs/sqb-entity-service.js +10 -10
- package/cjs/sqb-singleton-resource.js +5 -5
- package/esm/sqb-collection-resource.js +7 -7
- package/esm/sqb-entity-service.js +10 -10
- package/esm/sqb-singleton-resource.js +5 -5
- package/package.json +2 -2
- package/types/sqb-entity-service.d.ts +10 -10
|
@@ -8,32 +8,32 @@ class SqbCollectionResource {
|
|
|
8
8
|
async create(ctx) {
|
|
9
9
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
10
10
|
const service = await this.getService(ctx);
|
|
11
|
-
return service.create(
|
|
11
|
+
return service.with(ctx).create(prepared.data, prepared.options);
|
|
12
12
|
}
|
|
13
13
|
async delete(ctx) {
|
|
14
14
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
15
15
|
const service = await this.getService(ctx);
|
|
16
|
-
return service.delete(
|
|
16
|
+
return service.with(ctx).delete(prepared.key, prepared.options);
|
|
17
17
|
}
|
|
18
18
|
async deleteMany(ctx) {
|
|
19
19
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
20
20
|
const service = await this.getService(ctx);
|
|
21
|
-
return service.deleteMany(
|
|
21
|
+
return service.with(ctx).deleteMany(prepared.options);
|
|
22
22
|
}
|
|
23
23
|
async find(ctx) {
|
|
24
24
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
25
25
|
const service = await this.getService(ctx);
|
|
26
|
-
return service.find(
|
|
26
|
+
return service.with(ctx).find(prepared.key, prepared.options);
|
|
27
27
|
}
|
|
28
28
|
async update(ctx) {
|
|
29
29
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
30
30
|
const service = await this.getService(ctx);
|
|
31
|
-
return service.update(
|
|
31
|
+
return service.with(ctx).update(prepared.key, prepared.data, prepared.options);
|
|
32
32
|
}
|
|
33
33
|
async updateMany(ctx) {
|
|
34
34
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
35
35
|
const service = await this.getService(ctx);
|
|
36
|
-
return service.updateMany(
|
|
36
|
+
return service.with(ctx).updateMany(prepared.data, prepared.options);
|
|
37
37
|
}
|
|
38
38
|
async search(ctx) {
|
|
39
39
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
@@ -47,7 +47,7 @@ class SqbCollectionResource {
|
|
|
47
47
|
return items;
|
|
48
48
|
}
|
|
49
49
|
else
|
|
50
|
-
return service.findAll(
|
|
50
|
+
return service.with(ctx).findAll(prepared.options);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
tslib_1.__decorate([
|
|
@@ -11,7 +11,7 @@ class SqbEntityService {
|
|
|
11
11
|
this.db = options?.db;
|
|
12
12
|
this.defaultLimit = options?.defaultLimit || 10;
|
|
13
13
|
}
|
|
14
|
-
async count(
|
|
14
|
+
async count(options) {
|
|
15
15
|
const conn = await this.getConnection();
|
|
16
16
|
const repo = conn.getRepository(this.typeClass);
|
|
17
17
|
try {
|
|
@@ -22,7 +22,7 @@ class SqbEntityService {
|
|
|
22
22
|
throw e;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
async create(
|
|
25
|
+
async create(data, options) {
|
|
26
26
|
const conn = await this.getConnection();
|
|
27
27
|
const repo = conn.getRepository(this.typeClass);
|
|
28
28
|
let out;
|
|
@@ -39,7 +39,7 @@ class SqbEntityService {
|
|
|
39
39
|
throw new Error('"create" operation returned no result!');
|
|
40
40
|
return out;
|
|
41
41
|
}
|
|
42
|
-
async delete(
|
|
42
|
+
async delete(keyValue, options) {
|
|
43
43
|
const conn = await this.getConnection();
|
|
44
44
|
const repo = conn.getRepository(this.typeClass);
|
|
45
45
|
try {
|
|
@@ -50,7 +50,7 @@ class SqbEntityService {
|
|
|
50
50
|
throw e;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
async deleteMany(
|
|
53
|
+
async deleteMany(options) {
|
|
54
54
|
const conn = await this.getConnection();
|
|
55
55
|
const repo = conn.getRepository(this.typeClass);
|
|
56
56
|
try {
|
|
@@ -61,7 +61,7 @@ class SqbEntityService {
|
|
|
61
61
|
throw e;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
async find(
|
|
64
|
+
async find(keyValue, options) {
|
|
65
65
|
const conn = await this.getConnection();
|
|
66
66
|
const repo = conn.getRepository(this.typeClass);
|
|
67
67
|
let out;
|
|
@@ -76,7 +76,7 @@ class SqbEntityService {
|
|
|
76
76
|
out = this.onTransformRow(out);
|
|
77
77
|
return out;
|
|
78
78
|
}
|
|
79
|
-
async findOne(
|
|
79
|
+
async findOne(options) {
|
|
80
80
|
const conn = await this.getConnection();
|
|
81
81
|
const repo = conn.getRepository(this.typeClass);
|
|
82
82
|
let out;
|
|
@@ -91,7 +91,7 @@ class SqbEntityService {
|
|
|
91
91
|
out = this.onTransformRow(out);
|
|
92
92
|
return out;
|
|
93
93
|
}
|
|
94
|
-
async findAll(
|
|
94
|
+
async findAll(options) {
|
|
95
95
|
const conn = await this.getConnection();
|
|
96
96
|
const repo = conn.getRepository(this.typeClass);
|
|
97
97
|
let items;
|
|
@@ -113,7 +113,7 @@ class SqbEntityService {
|
|
|
113
113
|
}
|
|
114
114
|
return items;
|
|
115
115
|
}
|
|
116
|
-
async exists(
|
|
116
|
+
async exists(options) {
|
|
117
117
|
const conn = await this.getConnection();
|
|
118
118
|
const repo = conn.getRepository(this.typeClass);
|
|
119
119
|
try {
|
|
@@ -124,7 +124,7 @@ class SqbEntityService {
|
|
|
124
124
|
throw e;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
async update(
|
|
127
|
+
async update(keyValue, data, options) {
|
|
128
128
|
const conn = await this.getConnection();
|
|
129
129
|
const repo = conn.getRepository(this.typeClass);
|
|
130
130
|
let out;
|
|
@@ -139,7 +139,7 @@ class SqbEntityService {
|
|
|
139
139
|
out = this.onTransformRow(out);
|
|
140
140
|
return out;
|
|
141
141
|
}
|
|
142
|
-
async updateMany(
|
|
142
|
+
async updateMany(data, options) {
|
|
143
143
|
const conn = await this.getConnection();
|
|
144
144
|
const repo = conn.getRepository(this.typeClass);
|
|
145
145
|
try {
|
|
@@ -8,23 +8,23 @@ class SqbSingletonResource {
|
|
|
8
8
|
async create(ctx) {
|
|
9
9
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
10
10
|
const service = await this.getService(ctx);
|
|
11
|
-
return service.create(
|
|
11
|
+
return service.with(ctx).create(prepared.data, prepared.options);
|
|
12
12
|
}
|
|
13
13
|
async delete(ctx) {
|
|
14
14
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
15
15
|
const service = await this.getService(ctx);
|
|
16
|
-
return !!(await service.deleteMany(
|
|
16
|
+
return !!(await service.with(ctx).deleteMany(prepared.options));
|
|
17
17
|
}
|
|
18
18
|
async get(ctx) {
|
|
19
19
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
20
20
|
const service = await this.getService(ctx);
|
|
21
|
-
return service.findOne(
|
|
21
|
+
return service.with(ctx).findOne(prepared.options);
|
|
22
22
|
}
|
|
23
23
|
async update(ctx) {
|
|
24
24
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
25
25
|
const service = await this.getService(ctx);
|
|
26
|
-
await service.updateMany(
|
|
27
|
-
return service.findOne(
|
|
26
|
+
await service.with(ctx).updateMany(prepared.data, prepared.options);
|
|
27
|
+
return service.with(ctx).findOne(prepared.options);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
tslib_1.__decorate([
|
|
@@ -8,32 +8,32 @@ class SqbCollectionResource {
|
|
|
8
8
|
async create(ctx) {
|
|
9
9
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
10
10
|
const service = await this.getService(ctx);
|
|
11
|
-
return service.create(
|
|
11
|
+
return service.with(ctx).create(prepared.data, prepared.options);
|
|
12
12
|
}
|
|
13
13
|
async delete(ctx) {
|
|
14
14
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
15
15
|
const service = await this.getService(ctx);
|
|
16
|
-
return service.delete(
|
|
16
|
+
return service.with(ctx).delete(prepared.key, prepared.options);
|
|
17
17
|
}
|
|
18
18
|
async deleteMany(ctx) {
|
|
19
19
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
20
20
|
const service = await this.getService(ctx);
|
|
21
|
-
return service.deleteMany(
|
|
21
|
+
return service.with(ctx).deleteMany(prepared.options);
|
|
22
22
|
}
|
|
23
23
|
async find(ctx) {
|
|
24
24
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
25
25
|
const service = await this.getService(ctx);
|
|
26
|
-
return service.find(
|
|
26
|
+
return service.with(ctx).find(prepared.key, prepared.options);
|
|
27
27
|
}
|
|
28
28
|
async update(ctx) {
|
|
29
29
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
30
30
|
const service = await this.getService(ctx);
|
|
31
|
-
return service.update(
|
|
31
|
+
return service.with(ctx).update(prepared.key, prepared.data, prepared.options);
|
|
32
32
|
}
|
|
33
33
|
async updateMany(ctx) {
|
|
34
34
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
35
35
|
const service = await this.getService(ctx);
|
|
36
|
-
return service.updateMany(
|
|
36
|
+
return service.with(ctx).updateMany(prepared.data, prepared.options);
|
|
37
37
|
}
|
|
38
38
|
async search(ctx) {
|
|
39
39
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
@@ -47,7 +47,7 @@ class SqbCollectionResource {
|
|
|
47
47
|
return items;
|
|
48
48
|
}
|
|
49
49
|
else
|
|
50
|
-
return service.findAll(
|
|
50
|
+
return service.with(ctx).findAll(prepared.options);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
tslib_1.__decorate([
|
|
@@ -11,7 +11,7 @@ class SqbEntityService {
|
|
|
11
11
|
this.db = options?.db;
|
|
12
12
|
this.defaultLimit = options?.defaultLimit || 10;
|
|
13
13
|
}
|
|
14
|
-
async count(
|
|
14
|
+
async count(options) {
|
|
15
15
|
const conn = await this.getConnection();
|
|
16
16
|
const repo = conn.getRepository(this.typeClass);
|
|
17
17
|
try {
|
|
@@ -22,7 +22,7 @@ class SqbEntityService {
|
|
|
22
22
|
throw e;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
async create(
|
|
25
|
+
async create(data, options) {
|
|
26
26
|
const conn = await this.getConnection();
|
|
27
27
|
const repo = conn.getRepository(this.typeClass);
|
|
28
28
|
let out;
|
|
@@ -39,7 +39,7 @@ class SqbEntityService {
|
|
|
39
39
|
throw new Error('"create" operation returned no result!');
|
|
40
40
|
return out;
|
|
41
41
|
}
|
|
42
|
-
async delete(
|
|
42
|
+
async delete(keyValue, options) {
|
|
43
43
|
const conn = await this.getConnection();
|
|
44
44
|
const repo = conn.getRepository(this.typeClass);
|
|
45
45
|
try {
|
|
@@ -50,7 +50,7 @@ class SqbEntityService {
|
|
|
50
50
|
throw e;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
async deleteMany(
|
|
53
|
+
async deleteMany(options) {
|
|
54
54
|
const conn = await this.getConnection();
|
|
55
55
|
const repo = conn.getRepository(this.typeClass);
|
|
56
56
|
try {
|
|
@@ -61,7 +61,7 @@ class SqbEntityService {
|
|
|
61
61
|
throw e;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
async find(
|
|
64
|
+
async find(keyValue, options) {
|
|
65
65
|
const conn = await this.getConnection();
|
|
66
66
|
const repo = conn.getRepository(this.typeClass);
|
|
67
67
|
let out;
|
|
@@ -76,7 +76,7 @@ class SqbEntityService {
|
|
|
76
76
|
out = this.onTransformRow(out);
|
|
77
77
|
return out;
|
|
78
78
|
}
|
|
79
|
-
async findOne(
|
|
79
|
+
async findOne(options) {
|
|
80
80
|
const conn = await this.getConnection();
|
|
81
81
|
const repo = conn.getRepository(this.typeClass);
|
|
82
82
|
let out;
|
|
@@ -91,7 +91,7 @@ class SqbEntityService {
|
|
|
91
91
|
out = this.onTransformRow(out);
|
|
92
92
|
return out;
|
|
93
93
|
}
|
|
94
|
-
async findAll(
|
|
94
|
+
async findAll(options) {
|
|
95
95
|
const conn = await this.getConnection();
|
|
96
96
|
const repo = conn.getRepository(this.typeClass);
|
|
97
97
|
let items;
|
|
@@ -113,7 +113,7 @@ class SqbEntityService {
|
|
|
113
113
|
}
|
|
114
114
|
return items;
|
|
115
115
|
}
|
|
116
|
-
async exists(
|
|
116
|
+
async exists(options) {
|
|
117
117
|
const conn = await this.getConnection();
|
|
118
118
|
const repo = conn.getRepository(this.typeClass);
|
|
119
119
|
try {
|
|
@@ -124,7 +124,7 @@ class SqbEntityService {
|
|
|
124
124
|
throw e;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
async update(
|
|
127
|
+
async update(keyValue, data, options) {
|
|
128
128
|
const conn = await this.getConnection();
|
|
129
129
|
const repo = conn.getRepository(this.typeClass);
|
|
130
130
|
let out;
|
|
@@ -139,7 +139,7 @@ class SqbEntityService {
|
|
|
139
139
|
out = this.onTransformRow(out);
|
|
140
140
|
return out;
|
|
141
141
|
}
|
|
142
|
-
async updateMany(
|
|
142
|
+
async updateMany(data, options) {
|
|
143
143
|
const conn = await this.getConnection();
|
|
144
144
|
const repo = conn.getRepository(this.typeClass);
|
|
145
145
|
try {
|
|
@@ -8,23 +8,23 @@ class SqbSingletonResource {
|
|
|
8
8
|
async create(ctx) {
|
|
9
9
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
10
10
|
const service = await this.getService(ctx);
|
|
11
|
-
return service.create(
|
|
11
|
+
return service.with(ctx).create(prepared.data, prepared.options);
|
|
12
12
|
}
|
|
13
13
|
async delete(ctx) {
|
|
14
14
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
15
15
|
const service = await this.getService(ctx);
|
|
16
|
-
return !!(await service.deleteMany(
|
|
16
|
+
return !!(await service.with(ctx).deleteMany(prepared.options));
|
|
17
17
|
}
|
|
18
18
|
async get(ctx) {
|
|
19
19
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
20
20
|
const service = await this.getService(ctx);
|
|
21
|
-
return service.findOne(
|
|
21
|
+
return service.with(ctx).findOne(prepared.options);
|
|
22
22
|
}
|
|
23
23
|
async update(ctx) {
|
|
24
24
|
const prepared = sqb_adapter_js_1.SQBAdapter.transformRequest(ctx.request);
|
|
25
25
|
const service = await this.getService(ctx);
|
|
26
|
-
await service.updateMany(
|
|
27
|
-
return service.findOne(
|
|
26
|
+
await service.with(ctx).updateMany(prepared.data, prepared.options);
|
|
27
|
+
return service.with(ctx).findOne(prepared.options);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
tslib_1.__decorate([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/sqb",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"description": "Opra SQB adapter package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"ts-gems": "^2.3.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@opra/core": "^0.16.
|
|
40
|
+
"@opra/core": "^0.16.2",
|
|
41
41
|
"@sqb/connect": ">= 4.8.2"
|
|
42
42
|
},
|
|
43
43
|
"type": "module",
|
|
@@ -13,16 +13,16 @@ export declare class SqbEntityService<T, TOutput = PartialOutput<T>> {
|
|
|
13
13
|
defaultLimit: number;
|
|
14
14
|
db?: SqbClient | SqbConnection;
|
|
15
15
|
constructor(typeClass: Type<T>, options?: SqbEntityService.Options);
|
|
16
|
-
count(
|
|
17
|
-
create(
|
|
18
|
-
delete(
|
|
19
|
-
deleteMany(
|
|
20
|
-
find(
|
|
21
|
-
findOne(
|
|
22
|
-
findAll(
|
|
23
|
-
exists(
|
|
24
|
-
update(
|
|
25
|
-
updateMany(
|
|
16
|
+
count(options?: Repository.CountOptions): Promise<number>;
|
|
17
|
+
create(data: PartialInput<T>, options?: Repository.CreateOptions): Promise<TOutput>;
|
|
18
|
+
delete(keyValue: any, options?: Repository.DestroyOptions): Promise<boolean>;
|
|
19
|
+
deleteMany(options?: Repository.DestroyOptions): Promise<number>;
|
|
20
|
+
find(keyValue: any, options?: Repository.FindOptions): Promise<Maybe<TOutput>>;
|
|
21
|
+
findOne(options?: Repository.FindOneOptions): Promise<Maybe<TOutput>>;
|
|
22
|
+
findAll(options?: Repository.FindManyOptions): Promise<TOutput[]>;
|
|
23
|
+
exists(options?: Repository.ExistsOptions): Promise<boolean>;
|
|
24
|
+
update(keyValue: any, data: EntityInput<T>, options?: Repository.UpdateOptions): Promise<Maybe<TOutput>>;
|
|
25
|
+
updateMany(data: PartialInput<T>, options?: Repository.UpdateManyOptions): Promise<number>;
|
|
26
26
|
with(context: RequestContext, db?: SqbClient | SqbConnection): SqbEntityService<T, TOutput>;
|
|
27
27
|
protected _onError(error: unknown): Promise<void>;
|
|
28
28
|
protected getConnection(): SqbConnection | SqbClient | Promise<SqbConnection | SqbClient>;
|