@opra/sqb 1.26.2 → 1.26.4
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/README.md +24 -1
- package/adapter-utils/prepare-filter.d.ts +3 -4
- package/adapter-utils/prepare-filter.js +3 -4
- package/augmentation/datatype-factory.augmentation.js +1 -1
- package/package.json +3 -3
- package/sqb-adapter.d.ts +41 -1
- package/sqb-adapter.js +21 -6
- package/sqb-collection-service.d.ts +141 -159
- package/sqb-collection-service.js +52 -99
- package/sqb-entity-service.d.ts +131 -153
- package/sqb-entity-service.js +123 -127
- package/sqb-service-base.d.ts +18 -14
- package/sqb-service-base.js +15 -17
- package/sqb-singleton-service.d.ts +78 -88
- package/sqb-singleton-service.js +26 -26
package/README.md
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
1
|
# @opra/sqb
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[![NPM Version][npm-image]][npm-url]
|
|
4
|
+
[![NPM Downloads][downloads-image]][downloads-url]
|
|
5
|
+
[![CI Tests][ci-test-image]][ci-test-url]
|
|
6
|
+
[![Test Coverage][coveralls-image]][coveralls-url]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## Support
|
|
10
|
+
You can report bugs and discuss features on the [GitHub issues](https://github.com/panates/opra/issues) page.
|
|
11
|
+
|
|
12
|
+
## Node Compatibility
|
|
13
|
+
- node >= 20.x
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## License
|
|
17
|
+
Available under [MIT](LICENSE) license.
|
|
18
|
+
|
|
19
|
+
[npm-image]: https://img.shields.io/npm/v/@opra/sqb
|
|
20
|
+
[npm-url]: https://npmjs.org/package/@opra/sqb
|
|
21
|
+
[downloads-image]: https://img.shields.io/npm/dm/@opra/sqb.svg
|
|
22
|
+
[downloads-url]: https://npmjs.org/package/@opra/sqb
|
|
23
|
+
[ci-test-image]: https://github.com/panates/opra/actions/workflows/test.yml/badge.svg
|
|
24
|
+
[ci-test-url]: https://github.com/panates/opra/actions/workflows/test.yml
|
|
25
|
+
[coveralls-image]: https://coveralls.io/repos/github/panates/opra/badge.svg?branch=main
|
|
26
|
+
[coveralls-url]: https://coveralls.io/github/panates/opra?branch=main
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import '@opra/core';
|
|
2
2
|
import type { SQBAdapter } from '../sqb-adapter.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Prepares the SQB filter based on the provided filters and options.
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
7
|
-
*
|
|
8
|
-
* @returns {Expression} - The prepared SQB Expression.
|
|
6
|
+
* @param filters - The filter(s) to be applied. Can be a single filter or an array of filters.
|
|
7
|
+
* @returns The prepared SQB Expression, or `undefined` if no filters are provided.
|
|
9
8
|
*/
|
|
10
9
|
export default function prepareFilter(filters: SQBAdapter.FilterInput | SQBAdapter.FilterInput[]): any;
|
|
@@ -3,11 +3,10 @@ import { OpraFilter } from '@opra/common';
|
|
|
3
3
|
import * as sqb from '@sqb/builder';
|
|
4
4
|
import { vg } from 'valgen';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Prepares the SQB filter based on the provided filters and options.
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
9
|
-
*
|
|
10
|
-
* @returns {Expression} - The prepared SQB Expression.
|
|
8
|
+
* @param filters - The filter(s) to be applied. Can be a single filter or an array of filters.
|
|
9
|
+
* @returns The prepared SQB Expression, or `undefined` if no filters are provided.
|
|
11
10
|
*/
|
|
12
11
|
export default function prepareFilter(filters) {
|
|
13
12
|
const filtersArray = Array.isArray(filters) ? filters : [filters];
|
|
@@ -13,7 +13,7 @@ DataTypeFactory._prepareComplexTypeArgs = async function (context, owner, initAr
|
|
|
13
13
|
const sqbField = sqbMeta && EntityMetadata.getField(sqbMeta, fieldName);
|
|
14
14
|
if (!sqbField)
|
|
15
15
|
continue;
|
|
16
|
-
|
|
16
|
+
/* Copy type information from sqb metadata to opra */
|
|
17
17
|
if (!fieldSchema.type || fieldSchema.type === Object) {
|
|
18
18
|
if (isAssociationField(sqbField)) {
|
|
19
19
|
if (!fieldSchema.type) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/sqb",
|
|
3
|
-
"version": "1.26.
|
|
3
|
+
"version": "1.26.4",
|
|
4
4
|
"description": "Opra SQB adapter package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"valgen": "^6.0.3"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@opra/core": "^1.26.
|
|
14
|
-
"@opra/http": "^1.26.
|
|
13
|
+
"@opra/core": "^1.26.4",
|
|
14
|
+
"@opra/http": "^1.26.4",
|
|
15
15
|
"@sqb/builder": ">4.0.0 <5",
|
|
16
16
|
"@sqb/connect": ">4.0.0 <5"
|
|
17
17
|
},
|
package/sqb-adapter.d.ts
CHANGED
|
@@ -2,20 +2,60 @@ import type { OpraFilter } from '@opra/common';
|
|
|
2
2
|
import type { ExecutionContext } from '@opra/core';
|
|
3
3
|
import { type Repository } from '@sqb/connect';
|
|
4
4
|
import _prepareFilter from './adapter-utils/prepare-filter.js';
|
|
5
|
+
/**
|
|
6
|
+
* SQBAdapter namespace provides types and utility functions for integrating SQB with Opra.
|
|
7
|
+
*/
|
|
5
8
|
export declare namespace SQBAdapter {
|
|
9
|
+
/**
|
|
10
|
+
* Represents a single identifier type.
|
|
11
|
+
*/
|
|
6
12
|
type Id = string | number | boolean | Date;
|
|
13
|
+
/**
|
|
14
|
+
* Represents a single identifier or a composite key.
|
|
15
|
+
*/
|
|
7
16
|
type IdOrIds = Id | Record<string, Id>;
|
|
17
|
+
/**
|
|
18
|
+
* Represents the input for a filter, which can be an Opra filter expression,
|
|
19
|
+
* a SQB filter object, a string, or undefined.
|
|
20
|
+
*/
|
|
8
21
|
type FilterInput = OpraFilter.Expression | Repository.FindManyOptions['filter'] | string | undefined;
|
|
9
22
|
/**
|
|
10
|
-
*
|
|
23
|
+
* Parses the given filter input into a SQB filter expression.
|
|
24
|
+
* @deprecated Use {@link prepareFilter} instead.
|
|
11
25
|
*/
|
|
12
26
|
const parseFilter: typeof _prepareFilter;
|
|
27
|
+
/**
|
|
28
|
+
* Prepares the given filter input into a SQB filter expression.
|
|
29
|
+
*/
|
|
13
30
|
const prepareFilter: typeof _prepareFilter;
|
|
31
|
+
/**
|
|
32
|
+
* Represents a request that has been transformed for SQB operations.
|
|
33
|
+
*/
|
|
14
34
|
interface TransformedRequest {
|
|
35
|
+
/**
|
|
36
|
+
* The operation method name.
|
|
37
|
+
*/
|
|
15
38
|
method: 'create' | 'delete' | 'deleteMany' | 'get' | 'replace' | 'findMany' | 'update' | 'updateMany';
|
|
39
|
+
/**
|
|
40
|
+
* The primary key for the operation, if applicable.
|
|
41
|
+
*/
|
|
16
42
|
key?: any;
|
|
43
|
+
/**
|
|
44
|
+
* The data object for create or update operations.
|
|
45
|
+
*/
|
|
17
46
|
data?: any;
|
|
47
|
+
/**
|
|
48
|
+
* Additional options for the SQB operation.
|
|
49
|
+
*/
|
|
18
50
|
options: any;
|
|
19
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Parses an execution context and transforms it into a SQB-compatible request.
|
|
54
|
+
*
|
|
55
|
+
* @param context - The execution context to parse.
|
|
56
|
+
* @returns A promise that resolves to the transformed request.
|
|
57
|
+
* @throws {TypeError} If the context transport is not 'http'.
|
|
58
|
+
* @throws {Error} If the operation is not compatible with SQB Adapter.
|
|
59
|
+
*/
|
|
20
60
|
function parseRequest(context: ExecutionContext): Promise<TransformedRequest>;
|
|
21
61
|
}
|
package/sqb-adapter.js
CHANGED
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
import { EntityMetadata } from '@sqb/connect';
|
|
2
2
|
import _prepareFilter from './adapter-utils/prepare-filter.js';
|
|
3
|
+
/**
|
|
4
|
+
* SQBAdapter namespace provides types and utility functions for integrating SQB with Opra.
|
|
5
|
+
*/
|
|
3
6
|
export var SQBAdapter;
|
|
4
7
|
(function (SQBAdapter) {
|
|
5
8
|
/**
|
|
6
|
-
*
|
|
9
|
+
* Parses the given filter input into a SQB filter expression.
|
|
10
|
+
* @deprecated Use {@link prepareFilter} instead.
|
|
7
11
|
*/
|
|
8
12
|
SQBAdapter.parseFilter = _prepareFilter;
|
|
13
|
+
/**
|
|
14
|
+
* Prepares the given filter input into a SQB filter expression.
|
|
15
|
+
*/
|
|
9
16
|
SQBAdapter.prepareFilter = _prepareFilter;
|
|
17
|
+
/**
|
|
18
|
+
* Parses an execution context and transforms it into a SQB-compatible request.
|
|
19
|
+
*
|
|
20
|
+
* @param context - The execution context to parse.
|
|
21
|
+
* @returns A promise that resolves to the transformed request.
|
|
22
|
+
* @throws {TypeError} If the context transport is not 'http'.
|
|
23
|
+
* @throws {Error} If the operation is not compatible with SQB Adapter.
|
|
24
|
+
*/
|
|
10
25
|
async function parseRequest(context) {
|
|
11
26
|
if (context.transport !== 'http') {
|
|
12
27
|
throw new TypeError('SQBAdapter can parse only HttpContext');
|
|
@@ -37,7 +52,7 @@ export var SQBAdapter;
|
|
|
37
52
|
controller.parameters.find(p => p.keyParam);
|
|
38
53
|
const key = keyParam && ctx.pathParams[String(keyParam.name)];
|
|
39
54
|
const options = {
|
|
40
|
-
filter: SQBAdapter.
|
|
55
|
+
filter: SQBAdapter.prepareFilter(ctx.queryParams.filter),
|
|
41
56
|
};
|
|
42
57
|
return {
|
|
43
58
|
method: 'delete',
|
|
@@ -47,14 +62,14 @@ export var SQBAdapter;
|
|
|
47
62
|
}
|
|
48
63
|
case 'Entity.DeleteMany': {
|
|
49
64
|
const options = {
|
|
50
|
-
filter: SQBAdapter.
|
|
65
|
+
filter: SQBAdapter.prepareFilter(ctx.queryParams.filter),
|
|
51
66
|
};
|
|
52
67
|
return { method: 'deleteMany', options };
|
|
53
68
|
}
|
|
54
69
|
case 'Entity.FindMany': {
|
|
55
70
|
const options = {
|
|
56
71
|
count: ctx.queryParams.count,
|
|
57
|
-
filter: SQBAdapter.
|
|
72
|
+
filter: SQBAdapter.prepareFilter(ctx.queryParams.filter),
|
|
58
73
|
projection: ctx.queryParams.projection ||
|
|
59
74
|
__oprDef.compositionOptions.defaultProjection,
|
|
60
75
|
limit: ctx.queryParams.limit || __oprDef.compositionOptions.defaultLimit,
|
|
@@ -96,7 +111,7 @@ export var SQBAdapter;
|
|
|
96
111
|
const key = keyParam && ctx.pathParams[String(keyParam.name)];
|
|
97
112
|
const options = {
|
|
98
113
|
projection: ctx.queryParams.projection,
|
|
99
|
-
filter: SQBAdapter.
|
|
114
|
+
filter: SQBAdapter.prepareFilter(ctx.queryParams.filter),
|
|
100
115
|
};
|
|
101
116
|
return {
|
|
102
117
|
method: 'update',
|
|
@@ -108,7 +123,7 @@ export var SQBAdapter;
|
|
|
108
123
|
case 'Entity.UpdateMany': {
|
|
109
124
|
const data = await ctx.getBody();
|
|
110
125
|
const options = {
|
|
111
|
-
filter: SQBAdapter.
|
|
126
|
+
filter: SQBAdapter.prepareFilter(ctx.queryParams.filter),
|
|
112
127
|
};
|
|
113
128
|
return {
|
|
114
129
|
method: 'updateMany',
|
|
@@ -1,243 +1,225 @@
|
|
|
1
|
-
import type { PartialDTO, PatchDTO, RequiredSome, Type } from 'ts-gems';
|
|
1
|
+
import type { DTO, PartialDTO, PatchDTO, RequiredSome, Type } from 'ts-gems';
|
|
2
2
|
import { SQBAdapter } from './sqb-adapter.js';
|
|
3
3
|
import { SqbEntityService } from './sqb-entity-service.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Options for SqbCollectionService.
|
|
6
6
|
*/
|
|
7
7
|
export declare namespace SqbCollectionService {
|
|
8
|
+
/**
|
|
9
|
+
* Configuration options for SqbCollectionService.
|
|
10
|
+
*/
|
|
8
11
|
interface Options extends SqbEntityService.Options {
|
|
12
|
+
/**
|
|
13
|
+
* Default maximum number of records returned by `findMany`.
|
|
14
|
+
*/
|
|
9
15
|
defaultLimit?: SqbCollectionService<any>['defaultLimit'];
|
|
16
|
+
/**
|
|
17
|
+
* Optional interceptor for the service operations.
|
|
18
|
+
*/
|
|
10
19
|
interceptor?: SqbCollectionService<any>['interceptor'];
|
|
11
20
|
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Service for managing a collection of entities backed by an SQB data source.
|
|
24
|
+
*
|
|
25
|
+
* @typeParam T - The entity type managed by this service
|
|
26
|
+
*/
|
|
27
|
+
export declare class SqbCollectionService<T extends object = object> extends SqbEntityService<T> {
|
|
12
28
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @interface
|
|
29
|
+
* Default maximum number of records returned by `findMany`.
|
|
16
30
|
*/
|
|
17
|
-
|
|
18
|
-
}
|
|
31
|
+
defaultLimit: number;
|
|
19
32
|
/**
|
|
20
|
-
*
|
|
33
|
+
* Constructs a new instance.
|
|
21
34
|
*
|
|
22
|
-
* @
|
|
35
|
+
* @param dataType - The data type of the collection elements.
|
|
36
|
+
* @param options - Options for the collection service.
|
|
23
37
|
*/
|
|
24
|
-
|
|
25
|
-
}
|
|
38
|
+
constructor(dataType: Type<T> | string, options?: SqbCollectionService.Options);
|
|
26
39
|
/**
|
|
27
|
-
*
|
|
40
|
+
* Asserts that a resource with the given ID exists.
|
|
41
|
+
* Throws {@link ResourceNotAvailableError} if it does not.
|
|
28
42
|
*
|
|
29
|
-
* @
|
|
43
|
+
* @param id - The ID of the resource to check.
|
|
44
|
+
* @param options - Optional existence check options.
|
|
45
|
+
* @throws {@link ResourceNotAvailableError} If the resource does not exist.
|
|
30
46
|
*/
|
|
31
|
-
|
|
32
|
-
}
|
|
47
|
+
assert(id: SQBAdapter.IdOrIds, options?: SqbEntityService.ExistsOptions): Promise<void>;
|
|
33
48
|
/**
|
|
34
|
-
*
|
|
49
|
+
* Creates a new resource and returns it with the requested projection.
|
|
35
50
|
*
|
|
36
|
-
* @
|
|
51
|
+
* @param input - The input data for the new resource.
|
|
52
|
+
* @param options - Options including a required `projection`.
|
|
53
|
+
* @returns The created resource as a partial DTO.
|
|
37
54
|
*/
|
|
38
|
-
|
|
39
|
-
}
|
|
55
|
+
create(input: PartialDTO<T>, options: RequiredSome<SqbEntityService.CreateOptions, 'projection'>): Promise<PartialDTO<T>>;
|
|
40
56
|
/**
|
|
41
|
-
*
|
|
57
|
+
* Creates a new resource and returns the full DTO.
|
|
42
58
|
*
|
|
43
|
-
* @
|
|
59
|
+
* @param input - The input data for the new resource.
|
|
60
|
+
* @param options - Optional create options.
|
|
61
|
+
* @returns The created resource as a full DTO.
|
|
44
62
|
*/
|
|
45
|
-
|
|
46
|
-
}
|
|
63
|
+
create(input: PartialDTO<T>, options?: SqbEntityService.CreateOptions): Promise<T>;
|
|
47
64
|
/**
|
|
48
|
-
*
|
|
65
|
+
* Creates a new resource without returning it.
|
|
49
66
|
*
|
|
50
|
-
* @
|
|
67
|
+
* @param input - The input data for the new resource.
|
|
68
|
+
* @param options - Optional create options.
|
|
51
69
|
*/
|
|
52
|
-
|
|
53
|
-
}
|
|
70
|
+
createOnly(input: PartialDTO<T>, options?: SqbEntityService.CreateOptions): Promise<void>;
|
|
54
71
|
/**
|
|
55
|
-
*
|
|
72
|
+
* Returns the number of records matching the given options.
|
|
56
73
|
*
|
|
57
|
-
* @
|
|
74
|
+
* @param options - Options for the count operation.
|
|
75
|
+
* @returns The number of matching records.
|
|
58
76
|
*/
|
|
59
|
-
|
|
60
|
-
}
|
|
77
|
+
count(options?: SqbEntityService.CountOptions): Promise<number>;
|
|
61
78
|
/**
|
|
62
|
-
*
|
|
79
|
+
* Deletes the record with the given ID.
|
|
63
80
|
*
|
|
64
|
-
* @
|
|
81
|
+
* @param id - The ID of the record to delete.
|
|
82
|
+
* @param options - Optional delete options.
|
|
83
|
+
* @returns The number of records deleted.
|
|
65
84
|
*/
|
|
66
|
-
|
|
67
|
-
}
|
|
85
|
+
delete(id: SQBAdapter.IdOrIds, options?: SqbEntityService.DeleteOptions): Promise<number>;
|
|
68
86
|
/**
|
|
69
|
-
*
|
|
87
|
+
* Deletes all records matching the given options.
|
|
70
88
|
*
|
|
71
|
-
* @
|
|
89
|
+
* @param options - Options including filter criteria.
|
|
90
|
+
* @returns The number of records deleted.
|
|
72
91
|
*/
|
|
73
|
-
|
|
74
|
-
}
|
|
92
|
+
deleteMany(options?: SqbEntityService.DeleteManyOptions): Promise<number>;
|
|
75
93
|
/**
|
|
76
|
-
*
|
|
94
|
+
* Checks whether a record with the given ID exists.
|
|
77
95
|
*
|
|
78
|
-
* @
|
|
96
|
+
* @param id - The ID to check.
|
|
97
|
+
* @param options - Optional query options.
|
|
98
|
+
* @returns `true` if the record exists, `false` otherwise.
|
|
79
99
|
*/
|
|
80
|
-
|
|
81
|
-
}
|
|
100
|
+
exists(id: SQBAdapter.IdOrIds, options?: SqbEntityService.ExistsOptions): Promise<boolean>;
|
|
82
101
|
/**
|
|
83
|
-
*
|
|
102
|
+
* Checks whether any record matching the given options exists.
|
|
84
103
|
*
|
|
85
|
-
* @
|
|
104
|
+
* @param options - Optional query options.
|
|
105
|
+
* @returns `true` if at least one matching record exists, `false` otherwise.
|
|
86
106
|
*/
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* @class SqbCollectionService
|
|
92
|
-
* @template T - The data type class type of the resource
|
|
93
|
-
*/
|
|
94
|
-
export declare class SqbCollectionService<T extends object = object> extends SqbEntityService<T> {
|
|
95
|
-
/**
|
|
96
|
-
* Represents default limit for findMany operation
|
|
97
|
-
*/
|
|
98
|
-
defaultLimit: number;
|
|
99
|
-
/**
|
|
100
|
-
* Constructs a new instance
|
|
101
|
-
*
|
|
102
|
-
* @param {Type | string} dataType - The data type of the array elements.
|
|
103
|
-
* @param {SqbCollectionService.Options} [options] - The options for the array service.
|
|
104
|
-
* @constructor
|
|
105
|
-
*/
|
|
106
|
-
constructor(dataType: Type<T> | string, options?: SqbCollectionService.Options);
|
|
107
|
-
/**
|
|
108
|
-
* Asserts the existence of a resource with the given ID.
|
|
109
|
-
* Throws a ResourceNotFoundError if the resource does not exist.
|
|
110
|
-
*
|
|
111
|
-
* @param {SQBAdapter.IdOrIds} id - The ID of the resource to assert.
|
|
112
|
-
* @param {SqbCollectionService.ExistsOptions} [options] - Optional options for checking the existence.
|
|
113
|
-
* @returns {Promise<void>} - A Promise that resolves when the resource exists.
|
|
114
|
-
* @throws {ResourceNotAvailableError} - If the resource does not exist.
|
|
115
|
-
*/
|
|
116
|
-
assert(id: SQBAdapter.IdOrIds, options?: SqbCollectionService.ExistsOptions): Promise<void>;
|
|
107
|
+
existsOne(options?: SqbEntityService.ExistsOptions): Promise<boolean>;
|
|
117
108
|
/**
|
|
118
|
-
*
|
|
109
|
+
* Finds a record by ID and returns it with the requested projection.
|
|
119
110
|
*
|
|
120
|
-
* @param
|
|
121
|
-
* @param
|
|
122
|
-
* @returns
|
|
123
|
-
* @throws {Error} if an unknown error occurs while creating the resource
|
|
111
|
+
* @param id - The ID of the record.
|
|
112
|
+
* @param options - Options including a required `projection`.
|
|
113
|
+
* @returns The found record as a partial DTO, or `undefined` if not found.
|
|
124
114
|
*/
|
|
125
|
-
|
|
126
|
-
create(input: PartialDTO<T>, options?: SqbCollectionService.CreateOptions): Promise<T>;
|
|
115
|
+
findById(id: SQBAdapter.IdOrIds, options?: RequiredSome<SqbEntityService.FindOneOptions, 'projection'>): Promise<PartialDTO<T> | undefined>;
|
|
127
116
|
/**
|
|
128
|
-
*
|
|
117
|
+
* Finds a record by ID and returns the whole DTO.
|
|
129
118
|
*
|
|
130
|
-
* @param
|
|
131
|
-
* @param
|
|
132
|
-
* @returns
|
|
133
|
-
* @throws {Error} if an unknown error occurs while creating the resource
|
|
119
|
+
* @param id - The ID of the record.
|
|
120
|
+
* @param options - Optional query options.
|
|
121
|
+
* @returns The found record, or `undefined` if not found.
|
|
134
122
|
*/
|
|
135
|
-
|
|
123
|
+
findById(id: SQBAdapter.IdOrIds, options?: SqbEntityService.FindOneOptions): Promise<DTO<T> | undefined>;
|
|
136
124
|
/**
|
|
137
|
-
*
|
|
125
|
+
* Finds the first record matching the given options and returns it with the requested projection.
|
|
138
126
|
*
|
|
139
|
-
* @param
|
|
140
|
-
* @
|
|
127
|
+
* @param options - Options including a required `projection`.
|
|
128
|
+
* @returns A promise that resolves to the found record as a partial DTO, or `undefined` if not found.
|
|
141
129
|
*/
|
|
142
|
-
|
|
130
|
+
findOne(options: RequiredSome<SqbEntityService.FindOneOptions, 'projection'>): Promise<PartialDTO<T> | undefined>;
|
|
143
131
|
/**
|
|
144
|
-
*
|
|
132
|
+
* Finds the first record matching the given options and returns the whole DTO.
|
|
145
133
|
*
|
|
146
|
-
* @param
|
|
147
|
-
* @
|
|
148
|
-
* @return {Promise<number>} - A Promise that resolves to the number of documents deleted.
|
|
134
|
+
* @param options - Optional query options.
|
|
135
|
+
* @returns A promise that resolves to the found record, or `undefined` if not found.
|
|
149
136
|
*/
|
|
150
|
-
|
|
137
|
+
findOne(options?: SqbEntityService.FindOneOptions): Promise<DTO<T> | undefined>;
|
|
151
138
|
/**
|
|
152
|
-
*
|
|
139
|
+
* Finds multiple records matching the given options and returns partial DTOs.
|
|
153
140
|
*
|
|
154
|
-
* @param
|
|
155
|
-
* @
|
|
141
|
+
* @param options - Options including a required `projection`.
|
|
142
|
+
* @returns An array of matching records as partial DTOs.
|
|
156
143
|
*/
|
|
157
|
-
|
|
144
|
+
findMany(options?: RequiredSome<SqbEntityService.FindManyOptions, 'projection'>): Promise<PartialDTO<T>[]>;
|
|
158
145
|
/**
|
|
159
|
-
*
|
|
146
|
+
* Finds multiple records matching the given options and returns whole DTOs.
|
|
160
147
|
*
|
|
161
|
-
* @param
|
|
162
|
-
* @
|
|
163
|
-
* @return {Promise<boolean>} - A Promise that resolves to a boolean indicating whether the record exists or not.
|
|
148
|
+
* @param options - Optional query options.
|
|
149
|
+
* @returns An array of matching records as full DTOs.
|
|
164
150
|
*/
|
|
165
|
-
|
|
151
|
+
findMany(options?: SqbEntityService.FindManyOptions): Promise<DTO<T>[]>;
|
|
166
152
|
/**
|
|
167
|
-
*
|
|
153
|
+
* Finds multiple records and returns them together with the total count of matches.
|
|
168
154
|
*
|
|
169
|
-
* @param
|
|
170
|
-
* @
|
|
155
|
+
* @param options - Options including a required `projection`.
|
|
156
|
+
* @returns An object with `items` (partial DTOs) and `count` (total matches).
|
|
171
157
|
*/
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
* @param {SQBAdapter.IdOrIds} id - The ID of the record.
|
|
177
|
-
* @param {SqbCollectionService.FindOneOptions} [options] - The options for the find query.
|
|
178
|
-
* @return {Promise<PartialDTO<T | undefined>>} - A promise resolving to the found document, or undefined if not found.
|
|
179
|
-
*/
|
|
180
|
-
findById(id: SQBAdapter.IdOrIds, options?: SqbCollectionService.FindOneOptions): Promise<PartialDTO<T> | undefined>;
|
|
158
|
+
findManyWithCount(options?: RequiredSome<SqbEntityService.FindManyOptions, 'projection'>): Promise<{
|
|
159
|
+
count: number;
|
|
160
|
+
items: PartialDTO<T>[];
|
|
161
|
+
}>;
|
|
181
162
|
/**
|
|
182
|
-
* Finds
|
|
163
|
+
* Finds multiple records and returns them together with the total count of matches.
|
|
183
164
|
*
|
|
184
|
-
* @param
|
|
185
|
-
* @
|
|
165
|
+
* @param options - Optional query options.
|
|
166
|
+
* @returns An object with `items` (full DTOs) and `count` (total matches).
|
|
186
167
|
*/
|
|
187
|
-
|
|
168
|
+
findManyWithCount(options?: SqbEntityService.FindManyOptions): Promise<{
|
|
169
|
+
count: number;
|
|
170
|
+
items: DTO<T>[];
|
|
171
|
+
}>;
|
|
188
172
|
/**
|
|
189
|
-
*
|
|
173
|
+
* Retrieves a record by ID. Throws if the record does not exist.
|
|
190
174
|
*
|
|
191
|
-
* @param
|
|
192
|
-
* @
|
|
175
|
+
* @param id - The ID of the record to retrieve.
|
|
176
|
+
* @param options - Options including a required `projection`.
|
|
177
|
+
* @returns The record as a partial DTO.
|
|
178
|
+
* @throws {@link ResourceNotAvailableError} If the record does not exist.
|
|
193
179
|
*/
|
|
194
|
-
|
|
180
|
+
get(id: SQBAdapter.IdOrIds, options?: RequiredSome<SqbEntityService.FindOneOptions, 'projection'>): Promise<PartialDTO<T>>;
|
|
195
181
|
/**
|
|
196
|
-
*
|
|
197
|
-
* and total count that matched the given criteria
|
|
182
|
+
* Retrieves a record by ID. Throws if the record does not exist.
|
|
198
183
|
*
|
|
199
|
-
* @param
|
|
200
|
-
* @
|
|
184
|
+
* @param id - The ID of the record to retrieve.
|
|
185
|
+
* @param options - Optional query options.
|
|
186
|
+
* @returns The record as a full DTO.
|
|
187
|
+
* @throws {@link ResourceNotAvailableError} If the record does not exist.
|
|
201
188
|
*/
|
|
202
|
-
|
|
203
|
-
count: number;
|
|
204
|
-
items: PartialDTO<T>[];
|
|
205
|
-
}>;
|
|
189
|
+
get(id: SQBAdapter.IdOrIds, options?: SqbEntityService.FindOneOptions): Promise<DTO<T>>;
|
|
206
190
|
/**
|
|
207
|
-
*
|
|
191
|
+
* Updates a record by ID and returns the updated record with the requested projection.
|
|
208
192
|
*
|
|
209
|
-
* @param
|
|
210
|
-
* @param
|
|
211
|
-
* @
|
|
212
|
-
*
|
|
213
|
-
* @throws {ResourceNotAvailableError} - If the document with the specified ID does not exist.
|
|
193
|
+
* @param id - The ID of the record to update.
|
|
194
|
+
* @param input - The fields to update.
|
|
195
|
+
* @param options - Options including a required `projection`.
|
|
196
|
+
* @returns The updated record as a partial DTO, or `undefined` if not found.
|
|
214
197
|
*/
|
|
215
|
-
|
|
198
|
+
update(id: SQBAdapter.IdOrIds, input: PatchDTO<T>, options?: RequiredSome<SqbEntityService.UpdateOneOptions, 'projection'>): Promise<PartialDTO<T> | undefined>;
|
|
216
199
|
/**
|
|
217
|
-
* Updates a record
|
|
200
|
+
* Updates a record by ID and returns the full updated DTO.
|
|
218
201
|
*
|
|
219
|
-
* @param
|
|
220
|
-
* @param
|
|
221
|
-
* @param
|
|
222
|
-
* @returns
|
|
223
|
-
* undefined if the document was not found.
|
|
202
|
+
* @param id - The ID of the record to update.
|
|
203
|
+
* @param input - The fields to update.
|
|
204
|
+
* @param options - Optional update options.
|
|
205
|
+
* @returns The updated record as a full DTO, or `undefined` if not found.
|
|
224
206
|
*/
|
|
225
|
-
update(id: SQBAdapter.IdOrIds, input: PatchDTO<T>, options?:
|
|
207
|
+
update(id: SQBAdapter.IdOrIds, input: PatchDTO<T>, options?: SqbEntityService.UpdateOneOptions): Promise<DTO<T> | undefined>;
|
|
226
208
|
/**
|
|
227
|
-
* Updates a record
|
|
209
|
+
* Updates a record by ID without returning it.
|
|
228
210
|
*
|
|
229
|
-
* @param
|
|
230
|
-
* @param
|
|
231
|
-
* @param
|
|
232
|
-
* @returns
|
|
211
|
+
* @param id - The ID of the record to update.
|
|
212
|
+
* @param input - The fields to update.
|
|
213
|
+
* @param options - Optional update options.
|
|
214
|
+
* @returns The number of records modified.
|
|
233
215
|
*/
|
|
234
|
-
updateOnly(id: SQBAdapter.IdOrIds, input: PatchDTO<T>, options?:
|
|
216
|
+
updateOnly(id: SQBAdapter.IdOrIds, input: PatchDTO<T>, options?: SqbEntityService.UpdateOneOptions): Promise<number>;
|
|
235
217
|
/**
|
|
236
|
-
* Updates
|
|
218
|
+
* Updates all records matching the given options.
|
|
237
219
|
*
|
|
238
|
-
* @param
|
|
239
|
-
* @param
|
|
240
|
-
* @
|
|
220
|
+
* @param input - The fields to update.
|
|
221
|
+
* @param options - Options including filter criteria.
|
|
222
|
+
* @returns The number of records modified.
|
|
241
223
|
*/
|
|
242
|
-
updateMany(input: PatchDTO<T>, options?:
|
|
224
|
+
updateMany(input: PatchDTO<T>, options?: SqbEntityService.UpdateManyOptions): Promise<number>;
|
|
243
225
|
}
|