@sqb/connect 4.13.0 → 4.14.1
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.
|
@@ -78,7 +78,7 @@ class SqbConnection extends (0, strict_typed_events_1.TypedEventEmitterClass)(st
|
|
|
78
78
|
await this.emitAsyncSerial('close');
|
|
79
79
|
const intlcon = this._intlcon;
|
|
80
80
|
this._intlcon = undefined;
|
|
81
|
-
this.client.pool.release(intlcon, e => {
|
|
81
|
+
this.client.pool.release(intlcon, (e) => {
|
|
82
82
|
if (e)
|
|
83
83
|
this.client.emit('error', e);
|
|
84
84
|
});
|
|
@@ -9,6 +9,10 @@ const delete_command_js_1 = require("./commands/delete.command.js");
|
|
|
9
9
|
const find_command_js_1 = require("./commands/find.command.js");
|
|
10
10
|
const update_command_js_1 = require("./commands/update.command.js");
|
|
11
11
|
const extract_keyvalues_js_1 = require("./util/extract-keyvalues.js");
|
|
12
|
+
/**
|
|
13
|
+
* @class Repository
|
|
14
|
+
* @template T - The data type class type of the record
|
|
15
|
+
*/
|
|
12
16
|
class Repository extends (0, strict_typed_events_1.TypedEventEmitterClass)(strict_typed_events_1.AsyncEventEmitter) {
|
|
13
17
|
constructor(entityDef, executor, schema) {
|
|
14
18
|
super();
|
|
@@ -22,29 +26,74 @@ class Repository extends (0, strict_typed_events_1.TypedEventEmitterClass)(stric
|
|
|
22
26
|
get type() {
|
|
23
27
|
return this._entity.ctor;
|
|
24
28
|
}
|
|
25
|
-
create(
|
|
29
|
+
create(input, options) {
|
|
26
30
|
return this._execute(async (connection) => {
|
|
27
|
-
const keyValue = await this._create(
|
|
31
|
+
const keyValue = await this._create(input, { ...options, connection, returning: true });
|
|
28
32
|
const result = keyValue && (await this._find(keyValue, { ...options, connection }));
|
|
29
33
|
if (!result)
|
|
30
34
|
throw new Error('Unable to insert new row');
|
|
31
35
|
return result;
|
|
32
36
|
}, options);
|
|
33
37
|
}
|
|
34
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new resource but returns nothing
|
|
40
|
+
*
|
|
41
|
+
* @param {PartialDTO<T>} input - The input data
|
|
42
|
+
* @param {Repository.CreateOptions} [options] - The options object
|
|
43
|
+
* @throws {Error} if an unknown error occurs while creating the resource
|
|
44
|
+
*/
|
|
45
|
+
createOnly(input, options) {
|
|
35
46
|
return this._execute(async (connection) => {
|
|
36
|
-
await this._create(
|
|
47
|
+
await this._create(input, { ...options, connection, returning: false });
|
|
37
48
|
}, options);
|
|
38
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Returns the count of records based on the provided options
|
|
52
|
+
*
|
|
53
|
+
* @param {Repository.CountOptions} options - The options for the count operation.
|
|
54
|
+
* @return {Promise<number>} - A promise that resolves to the count of records
|
|
55
|
+
*/
|
|
56
|
+
count(options) {
|
|
57
|
+
return this._execute(async (connection) => this._count({ ...options, connection }), options);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Deletes a record from the collection.
|
|
61
|
+
*
|
|
62
|
+
* @param {any} keyValue - The ID of the resource to delete.
|
|
63
|
+
* @param {Repository.DeleteOptions} [options] - Optional delete options.
|
|
64
|
+
* @return {Promise<boolean>} - A Promise that resolves true or false. True when resource deleted.
|
|
65
|
+
*/
|
|
66
|
+
delete(keyValue, options) {
|
|
67
|
+
return this._execute(async (connection) => this._delete(keyValue, { ...options, connection }), options);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Deletes multiple documents from the collection that meet the specified filter criteria.
|
|
71
|
+
*
|
|
72
|
+
* @param {Repository.DeleteManyOptions} options - The options for the delete operation.
|
|
73
|
+
* @return {Promise<number>} - A promise that resolves to the number of resources deleted.
|
|
74
|
+
*/
|
|
75
|
+
deleteMany(options) {
|
|
76
|
+
return this._execute(async (connection) => this._deleteMany({ ...options, connection }), options);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Checks if a record with the given id exists.
|
|
80
|
+
*
|
|
81
|
+
* @param {any} keyValue - The id of the object to check.
|
|
82
|
+
* @param {Repository.ExistsOptions} [options] - The options for the query (optional).
|
|
83
|
+
* @return {Promise<boolean>} - A Promise that resolves to a boolean indicating whether the record exists or not.
|
|
84
|
+
*/
|
|
39
85
|
exists(keyValue, options) {
|
|
40
86
|
return this._execute(async (connection) => this._exists(keyValue, { ...options, connection }), options);
|
|
41
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Checks if a record with the given arguments exists.
|
|
90
|
+
*
|
|
91
|
+
* @param {Repository.ExistsOptions} [options] - The options for the query (optional).
|
|
92
|
+
* @return {Promise<boolean>} - A Promise that resolves to a boolean indicating whether the record exists or not.
|
|
93
|
+
*/
|
|
42
94
|
existsOne(options) {
|
|
43
95
|
return this._execute(async (connection) => this._existsOne({ ...options, connection }), options);
|
|
44
96
|
}
|
|
45
|
-
count(options) {
|
|
46
|
-
return this._execute(async (connection) => this._count({ ...options, connection }), options);
|
|
47
|
-
}
|
|
48
97
|
findById(keyValue, options) {
|
|
49
98
|
return this._execute(async (connection) => this._find(keyValue, { ...options, connection }), options);
|
|
50
99
|
}
|
|
@@ -57,25 +106,34 @@ class Repository extends (0, strict_typed_events_1.TypedEventEmitterClass)(stric
|
|
|
57
106
|
findMany(options) {
|
|
58
107
|
return this._execute(async (connection) => this._findMany({ ...options, connection }), options);
|
|
59
108
|
}
|
|
60
|
-
|
|
61
|
-
return this._execute(async (connection) => this._delete(keyValue, { ...options, connection }), options);
|
|
62
|
-
}
|
|
63
|
-
deleteMany(options) {
|
|
64
|
-
return this._execute(async (connection) => this._deleteMany({ ...options, connection }), options);
|
|
65
|
-
}
|
|
66
|
-
update(keyValue, values, options) {
|
|
109
|
+
update(keyValue, input, options) {
|
|
67
110
|
return this._execute(async (connection) => {
|
|
68
111
|
const opts = { ...options, connection };
|
|
69
|
-
const keyValues = await this._update(keyValue,
|
|
112
|
+
const keyValues = await this._update(keyValue, input, opts);
|
|
70
113
|
if (keyValues)
|
|
71
114
|
return this._find(keyValues, opts);
|
|
72
115
|
}, options);
|
|
73
116
|
}
|
|
74
|
-
|
|
75
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Updates a record in the collection with the specified ID and returns updated record count
|
|
119
|
+
*
|
|
120
|
+
* @param {any} keyValue - The ID of the document to update.
|
|
121
|
+
* @param {PatchDTO<T>} input - The partial input data to update the document with.
|
|
122
|
+
* @param {Repository.UpdateOptions} options - The options for updating the document.
|
|
123
|
+
* @returns {Promise<number>} - A Promise that resolves true or false. True when resource updated.
|
|
124
|
+
*/
|
|
125
|
+
updateOnly(keyValue, input, options) {
|
|
126
|
+
return this._execute(async (connection) => !!(await this._update(keyValue, input, { ...options, connection })), options);
|
|
76
127
|
}
|
|
77
|
-
|
|
78
|
-
|
|
128
|
+
/**
|
|
129
|
+
* Updates multiple records in the collection based on the specified input and options.
|
|
130
|
+
*
|
|
131
|
+
* @param {PatchDTO<T>} input - The partial input to update the documents with.
|
|
132
|
+
* @param {Repository.UpdateManyOptions} options - The options for updating the documents.
|
|
133
|
+
* @return {Promise<number>} - A promise that resolves to the number of documents matched and modified.
|
|
134
|
+
*/
|
|
135
|
+
updateMany(input, options) {
|
|
136
|
+
return this._execute(async (connection) => this._updateMany(input, { ...options, connection }));
|
|
79
137
|
}
|
|
80
138
|
async _execute(fn, opts) {
|
|
81
139
|
let connection = opts?.connection;
|
|
@@ -74,7 +74,7 @@ export class SqbConnection extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
|
74
74
|
await this.emitAsyncSerial('close');
|
|
75
75
|
const intlcon = this._intlcon;
|
|
76
76
|
this._intlcon = undefined;
|
|
77
|
-
this.client.pool.release(intlcon, e => {
|
|
77
|
+
this.client.pool.release(intlcon, (e) => {
|
|
78
78
|
if (e)
|
|
79
79
|
this.client.emit('error', e);
|
|
80
80
|
});
|
|
@@ -6,6 +6,10 @@ import { DeleteCommand } from './commands/delete.command.js';
|
|
|
6
6
|
import { FindCommand } from './commands/find.command.js';
|
|
7
7
|
import { UpdateCommand } from './commands/update.command.js';
|
|
8
8
|
import { extractKeyValues } from './util/extract-keyvalues.js';
|
|
9
|
+
/**
|
|
10
|
+
* @class Repository
|
|
11
|
+
* @template T - The data type class type of the record
|
|
12
|
+
*/
|
|
9
13
|
export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
10
14
|
constructor(entityDef, executor, schema) {
|
|
11
15
|
super();
|
|
@@ -19,29 +23,74 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
|
19
23
|
get type() {
|
|
20
24
|
return this._entity.ctor;
|
|
21
25
|
}
|
|
22
|
-
create(
|
|
26
|
+
create(input, options) {
|
|
23
27
|
return this._execute(async (connection) => {
|
|
24
|
-
const keyValue = await this._create(
|
|
28
|
+
const keyValue = await this._create(input, { ...options, connection, returning: true });
|
|
25
29
|
const result = keyValue && (await this._find(keyValue, { ...options, connection }));
|
|
26
30
|
if (!result)
|
|
27
31
|
throw new Error('Unable to insert new row');
|
|
28
32
|
return result;
|
|
29
33
|
}, options);
|
|
30
34
|
}
|
|
31
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new resource but returns nothing
|
|
37
|
+
*
|
|
38
|
+
* @param {PartialDTO<T>} input - The input data
|
|
39
|
+
* @param {Repository.CreateOptions} [options] - The options object
|
|
40
|
+
* @throws {Error} if an unknown error occurs while creating the resource
|
|
41
|
+
*/
|
|
42
|
+
createOnly(input, options) {
|
|
32
43
|
return this._execute(async (connection) => {
|
|
33
|
-
await this._create(
|
|
44
|
+
await this._create(input, { ...options, connection, returning: false });
|
|
34
45
|
}, options);
|
|
35
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Returns the count of records based on the provided options
|
|
49
|
+
*
|
|
50
|
+
* @param {Repository.CountOptions} options - The options for the count operation.
|
|
51
|
+
* @return {Promise<number>} - A promise that resolves to the count of records
|
|
52
|
+
*/
|
|
53
|
+
count(options) {
|
|
54
|
+
return this._execute(async (connection) => this._count({ ...options, connection }), options);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Deletes a record from the collection.
|
|
58
|
+
*
|
|
59
|
+
* @param {any} keyValue - The ID of the resource to delete.
|
|
60
|
+
* @param {Repository.DeleteOptions} [options] - Optional delete options.
|
|
61
|
+
* @return {Promise<boolean>} - A Promise that resolves true or false. True when resource deleted.
|
|
62
|
+
*/
|
|
63
|
+
delete(keyValue, options) {
|
|
64
|
+
return this._execute(async (connection) => this._delete(keyValue, { ...options, connection }), options);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Deletes multiple documents from the collection that meet the specified filter criteria.
|
|
68
|
+
*
|
|
69
|
+
* @param {Repository.DeleteManyOptions} options - The options for the delete operation.
|
|
70
|
+
* @return {Promise<number>} - A promise that resolves to the number of resources deleted.
|
|
71
|
+
*/
|
|
72
|
+
deleteMany(options) {
|
|
73
|
+
return this._execute(async (connection) => this._deleteMany({ ...options, connection }), options);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Checks if a record with the given id exists.
|
|
77
|
+
*
|
|
78
|
+
* @param {any} keyValue - The id of the object to check.
|
|
79
|
+
* @param {Repository.ExistsOptions} [options] - The options for the query (optional).
|
|
80
|
+
* @return {Promise<boolean>} - A Promise that resolves to a boolean indicating whether the record exists or not.
|
|
81
|
+
*/
|
|
36
82
|
exists(keyValue, options) {
|
|
37
83
|
return this._execute(async (connection) => this._exists(keyValue, { ...options, connection }), options);
|
|
38
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Checks if a record with the given arguments exists.
|
|
87
|
+
*
|
|
88
|
+
* @param {Repository.ExistsOptions} [options] - The options for the query (optional).
|
|
89
|
+
* @return {Promise<boolean>} - A Promise that resolves to a boolean indicating whether the record exists or not.
|
|
90
|
+
*/
|
|
39
91
|
existsOne(options) {
|
|
40
92
|
return this._execute(async (connection) => this._existsOne({ ...options, connection }), options);
|
|
41
93
|
}
|
|
42
|
-
count(options) {
|
|
43
|
-
return this._execute(async (connection) => this._count({ ...options, connection }), options);
|
|
44
|
-
}
|
|
45
94
|
findById(keyValue, options) {
|
|
46
95
|
return this._execute(async (connection) => this._find(keyValue, { ...options, connection }), options);
|
|
47
96
|
}
|
|
@@ -54,25 +103,34 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
|
54
103
|
findMany(options) {
|
|
55
104
|
return this._execute(async (connection) => this._findMany({ ...options, connection }), options);
|
|
56
105
|
}
|
|
57
|
-
|
|
58
|
-
return this._execute(async (connection) => this._delete(keyValue, { ...options, connection }), options);
|
|
59
|
-
}
|
|
60
|
-
deleteMany(options) {
|
|
61
|
-
return this._execute(async (connection) => this._deleteMany({ ...options, connection }), options);
|
|
62
|
-
}
|
|
63
|
-
update(keyValue, values, options) {
|
|
106
|
+
update(keyValue, input, options) {
|
|
64
107
|
return this._execute(async (connection) => {
|
|
65
108
|
const opts = { ...options, connection };
|
|
66
|
-
const keyValues = await this._update(keyValue,
|
|
109
|
+
const keyValues = await this._update(keyValue, input, opts);
|
|
67
110
|
if (keyValues)
|
|
68
111
|
return this._find(keyValues, opts);
|
|
69
112
|
}, options);
|
|
70
113
|
}
|
|
71
|
-
|
|
72
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Updates a record in the collection with the specified ID and returns updated record count
|
|
116
|
+
*
|
|
117
|
+
* @param {any} keyValue - The ID of the document to update.
|
|
118
|
+
* @param {PatchDTO<T>} input - The partial input data to update the document with.
|
|
119
|
+
* @param {Repository.UpdateOptions} options - The options for updating the document.
|
|
120
|
+
* @returns {Promise<number>} - A Promise that resolves true or false. True when resource updated.
|
|
121
|
+
*/
|
|
122
|
+
updateOnly(keyValue, input, options) {
|
|
123
|
+
return this._execute(async (connection) => !!(await this._update(keyValue, input, { ...options, connection })), options);
|
|
73
124
|
}
|
|
74
|
-
|
|
75
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Updates multiple records in the collection based on the specified input and options.
|
|
127
|
+
*
|
|
128
|
+
* @param {PatchDTO<T>} input - The partial input to update the documents with.
|
|
129
|
+
* @param {Repository.UpdateManyOptions} options - The options for updating the documents.
|
|
130
|
+
* @return {Promise<number>} - A promise that resolves to the number of documents matched and modified.
|
|
131
|
+
*/
|
|
132
|
+
updateMany(input, options) {
|
|
133
|
+
return this._execute(async (connection) => this._updateMany(input, { ...options, connection }));
|
|
76
134
|
}
|
|
77
135
|
async _execute(fn, opts) {
|
|
78
136
|
let connection = opts?.connection;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/connect",
|
|
3
3
|
"description": "Multi-dialect database connection framework written with TypeScript",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.14.1",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Eray Hanoglu <e.hanoglu@panates.com>",
|
|
@@ -35,26 +35,26 @@
|
|
|
35
35
|
"clean:cover": "rimraf ../../coverage/connect"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"debug": "^4.3.
|
|
38
|
+
"debug": "^4.3.6",
|
|
39
39
|
"doublylinked": "^2.5.4",
|
|
40
40
|
"fast-tokenizer": "^1.3.0",
|
|
41
|
-
"lightning-pool": "^4.
|
|
41
|
+
"lightning-pool": "^4.4.3",
|
|
42
42
|
"lodash": "^4.17.21",
|
|
43
|
-
"power-tasks": "^1.7.
|
|
43
|
+
"power-tasks": "^1.7.7",
|
|
44
44
|
"putil-isplainobject": "^1.1.5",
|
|
45
|
-
"putil-merge": "^3.
|
|
45
|
+
"putil-merge": "^3.13.0",
|
|
46
46
|
"putil-promisify": "^1.10.1",
|
|
47
47
|
"putil-varhelpers": "^1.6.5",
|
|
48
|
-
"strict-typed-events": "^2.
|
|
48
|
+
"strict-typed-events": "^2.4.0",
|
|
49
49
|
"ts-gems": "^3.4.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/debug": "^4.1.12",
|
|
53
53
|
"@types/lodash": "^4.17.7",
|
|
54
|
-
"
|
|
54
|
+
"postgrejs": "^2.15.4"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@sqb/builder": "^4.
|
|
57
|
+
"@sqb/builder": "^4.14.1",
|
|
58
58
|
"reflect-metadata": "^0.2.2"
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LogicalOperator } from '@sqb/builder';
|
|
2
|
-
import { PartialDTO, PatchDTO, StrictOmit, Type } from 'ts-gems';
|
|
2
|
+
import { PartialDTO, PatchDTO, RequiredSome, StrictOmit, Type } from 'ts-gems';
|
|
3
3
|
import { FieldInfoMap } from '../client/field-info-map.js';
|
|
4
4
|
import { SqbClient } from '../client/sqb-client.js';
|
|
5
5
|
import { SqbConnection } from '../client/sqb-connection.js';
|
|
@@ -54,6 +54,10 @@ interface RepositoryEvents {
|
|
|
54
54
|
acquire: (connection: SqbConnection) => Promise<void>;
|
|
55
55
|
}
|
|
56
56
|
declare const Repository_base: Type<import("strict-typed-events").TypedEventEmitter<any, RepositoryEvents, RepositoryEvents>>;
|
|
57
|
+
/**
|
|
58
|
+
* @class Repository
|
|
59
|
+
* @template T - The data type class type of the record
|
|
60
|
+
*/
|
|
57
61
|
export declare class Repository<T> extends Repository_base {
|
|
58
62
|
private readonly _executor;
|
|
59
63
|
private readonly _entity;
|
|
@@ -61,19 +65,114 @@ export declare class Repository<T> extends Repository_base {
|
|
|
61
65
|
constructor(entityDef: EntityMetadata, executor: SqbClient | SqbConnection, schema?: string);
|
|
62
66
|
get entity(): EntityMetadata;
|
|
63
67
|
get type(): Type<T>;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Creates a new resource
|
|
70
|
+
*
|
|
71
|
+
* @param {PartialDTO<T>} input - The input data
|
|
72
|
+
* @param {Repository.CreateOptions} [options] - The options object
|
|
73
|
+
* @returns {Promise<PartialDTO<T>>} A promise that resolves to the created resource
|
|
74
|
+
* @throws {Error} if an unknown error occurs while creating the resource
|
|
75
|
+
*/
|
|
76
|
+
create(input: PartialDTO<T>, options: RequiredSome<Repository.CreateOptions, 'projection'>): Promise<PartialDTO<T>>;
|
|
77
|
+
create(input: PartialDTO<T>, options?: Repository.CreateOptions): Promise<T>;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a new resource but returns nothing
|
|
80
|
+
*
|
|
81
|
+
* @param {PartialDTO<T>} input - The input data
|
|
82
|
+
* @param {Repository.CreateOptions} [options] - The options object
|
|
83
|
+
* @throws {Error} if an unknown error occurs while creating the resource
|
|
84
|
+
*/
|
|
85
|
+
createOnly(input: PartialDTO<T>, options?: StrictOmit<Repository.CreateOptions, keyof Projection>): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Returns the count of records based on the provided options
|
|
88
|
+
*
|
|
89
|
+
* @param {Repository.CountOptions} options - The options for the count operation.
|
|
90
|
+
* @return {Promise<number>} - A promise that resolves to the count of records
|
|
91
|
+
*/
|
|
68
92
|
count(options?: Repository.CountOptions): Promise<number>;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Deletes a record from the collection.
|
|
95
|
+
*
|
|
96
|
+
* @param {any} keyValue - The ID of the resource to delete.
|
|
97
|
+
* @param {Repository.DeleteOptions} [options] - Optional delete options.
|
|
98
|
+
* @return {Promise<boolean>} - A Promise that resolves true or false. True when resource deleted.
|
|
99
|
+
*/
|
|
72
100
|
delete(keyValue: any | Record<string, any>, options?: Repository.DeleteOptions): Promise<boolean>;
|
|
101
|
+
/**
|
|
102
|
+
* Deletes multiple documents from the collection that meet the specified filter criteria.
|
|
103
|
+
*
|
|
104
|
+
* @param {Repository.DeleteManyOptions} options - The options for the delete operation.
|
|
105
|
+
* @return {Promise<number>} - A promise that resolves to the number of resources deleted.
|
|
106
|
+
*/
|
|
73
107
|
deleteMany(options?: Repository.DeleteManyOptions): Promise<number>;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
108
|
+
/**
|
|
109
|
+
* Checks if a record with the given id exists.
|
|
110
|
+
*
|
|
111
|
+
* @param {any} keyValue - The id of the object to check.
|
|
112
|
+
* @param {Repository.ExistsOptions} [options] - The options for the query (optional).
|
|
113
|
+
* @return {Promise<boolean>} - A Promise that resolves to a boolean indicating whether the record exists or not.
|
|
114
|
+
*/
|
|
115
|
+
exists(keyValue: any | Record<string, any>, options?: Repository.ExistsOptions): Promise<boolean>;
|
|
116
|
+
/**
|
|
117
|
+
* Checks if a record with the given arguments exists.
|
|
118
|
+
*
|
|
119
|
+
* @param {Repository.ExistsOptions} [options] - The options for the query (optional).
|
|
120
|
+
* @return {Promise<boolean>} - A Promise that resolves to a boolean indicating whether the record exists or not.
|
|
121
|
+
*/
|
|
122
|
+
existsOne(options?: Repository.ExistsOptions): Promise<boolean>;
|
|
123
|
+
/**
|
|
124
|
+
* Finds a record by ID.
|
|
125
|
+
*
|
|
126
|
+
* @param {any} keyValue - The ID of the record.
|
|
127
|
+
* @param {Repository.FindOneOptions} [options] - The options for the find query.
|
|
128
|
+
* @return {Promise<PartialDTO<T | undefined>>} - A promise resolving to the found document, or undefined if not found.
|
|
129
|
+
*/
|
|
130
|
+
findById(keyValue: any | Record<string, any>, options: RequiredSome<Repository.FindOptions, 'projection'>): Promise<PartialDTO<T> | undefined>;
|
|
131
|
+
findById(keyValue: any | Record<string, any>, options?: Repository.FindOptions): Promise<T | undefined>;
|
|
132
|
+
/**
|
|
133
|
+
* Finds a record in the collection that matches the specified options.
|
|
134
|
+
*
|
|
135
|
+
* @param {Repository.FindOneOptions} options - The options for the query.
|
|
136
|
+
* @return {Promise<PartialDTO<T> | undefined>} A promise that resolves with the found document or undefined if no document is found.
|
|
137
|
+
*/
|
|
138
|
+
findOne(options: RequiredSome<Repository.FindOneOptions, 'projection'>): Promise<PartialDTO<T> | undefined>;
|
|
139
|
+
findOne(options?: Repository.FindOneOptions): Promise<T | undefined>;
|
|
140
|
+
/**
|
|
141
|
+
* Finds multiple records in collection.
|
|
142
|
+
*
|
|
143
|
+
* @param {Repository.FindManyOptions} options - The options for the find operation.
|
|
144
|
+
* @return A Promise that resolves to an array of partial outputs of type T.
|
|
145
|
+
*/
|
|
146
|
+
findMany(options: RequiredSome<Repository.FindManyOptions, 'projection'>): Promise<PartialDTO<T>[]>;
|
|
147
|
+
findMany(options?: Repository.FindManyOptions): Promise<T[]>;
|
|
148
|
+
/**
|
|
149
|
+
* Updates a record with the given id in the collection.
|
|
150
|
+
*
|
|
151
|
+
* @param {any} keyValue - The id of the document to update.
|
|
152
|
+
* @param {PatchDTO<T>} input - The partial input object containing the fields to update.
|
|
153
|
+
* @param {Repository.UpdateOptions} [options] - The options for the update operation.
|
|
154
|
+
* @returns {Promise<PartialDTO<T> | undefined>} A promise that resolves to the updated document or
|
|
155
|
+
* undefined if the document was not found.
|
|
156
|
+
*/
|
|
157
|
+
update(keyValue: any | Record<string, any>, input: PatchDTO<T>, options: RequiredSome<Repository.UpdateOptions, 'projection'>): Promise<PartialDTO<T> | undefined>;
|
|
158
|
+
update(keyValue: any | Record<string, any>, input: PatchDTO<T>, options?: Repository.UpdateOptions): Promise<T | undefined>;
|
|
159
|
+
/**
|
|
160
|
+
* Updates a record in the collection with the specified ID and returns updated record count
|
|
161
|
+
*
|
|
162
|
+
* @param {any} keyValue - The ID of the document to update.
|
|
163
|
+
* @param {PatchDTO<T>} input - The partial input data to update the document with.
|
|
164
|
+
* @param {Repository.UpdateOptions} options - The options for updating the document.
|
|
165
|
+
* @returns {Promise<number>} - A Promise that resolves true or false. True when resource updated.
|
|
166
|
+
*/
|
|
167
|
+
updateOnly(keyValue: any | Record<string, any>, input: PatchDTO<T>, options?: Repository.UpdateOnlyOptions): Promise<boolean>;
|
|
168
|
+
/**
|
|
169
|
+
* Updates multiple records in the collection based on the specified input and options.
|
|
170
|
+
*
|
|
171
|
+
* @param {PatchDTO<T>} input - The partial input to update the documents with.
|
|
172
|
+
* @param {Repository.UpdateManyOptions} options - The options for updating the documents.
|
|
173
|
+
* @return {Promise<number>} - A promise that resolves to the number of documents matched and modified.
|
|
174
|
+
*/
|
|
175
|
+
updateMany(input: PartialDTO<T>, options?: Repository.UpdateManyOptions): Promise<number>;
|
|
77
176
|
protected _execute(fn: TransactionFunction, opts?: Repository.CommandOptions): Promise<any>;
|
|
78
177
|
protected _create(values: PartialDTO<T>, options: Repository.CreateOptions & {
|
|
79
178
|
connection: SqbConnection;
|