@sqb/connect 4.16.1 → 4.18.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.
|
@@ -8,6 +8,7 @@ const create_command_js_1 = require("./commands/create.command.js");
|
|
|
8
8
|
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
|
+
const entity_metadata_js_1 = require("./model/entity-metadata.js");
|
|
11
12
|
const extract_keyvalues_js_1 = require("./util/extract-keyvalues.js");
|
|
12
13
|
/**
|
|
13
14
|
* @class Repository
|
|
@@ -40,11 +41,16 @@ class Repository extends (0, strict_typed_events_1.TypedEventEmitterClass)(stric
|
|
|
40
41
|
*
|
|
41
42
|
* @param {PartialDTO<T>} input - The input data
|
|
42
43
|
* @param {Repository.CreateOptions} [options] - The options object
|
|
44
|
+
* @returns {Promise<any>} A promise that resolves key value(s) of the created record
|
|
43
45
|
* @throws {Error} if an unknown error occurs while creating the resource
|
|
44
46
|
*/
|
|
45
47
|
createOnly(input, options) {
|
|
46
48
|
return this._execute(async (connection) => {
|
|
47
|
-
await this._create(input, { ...options, connection, returning:
|
|
49
|
+
const r = await this._create(input, { ...options, connection, returning: true });
|
|
50
|
+
const primaryIndex = entity_metadata_js_1.EntityMetadata.getPrimaryIndex(this.entity);
|
|
51
|
+
if (!primaryIndex || primaryIndex.columns.length > 1)
|
|
52
|
+
return r;
|
|
53
|
+
return r[primaryIndex.columns[0]];
|
|
48
54
|
}, options);
|
|
49
55
|
}
|
|
50
56
|
/**
|
|
@@ -5,6 +5,7 @@ import { CreateCommand } from './commands/create.command.js';
|
|
|
5
5
|
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
|
+
import { EntityMetadata } from './model/entity-metadata.js';
|
|
8
9
|
import { extractKeyValues } from './util/extract-keyvalues.js';
|
|
9
10
|
/**
|
|
10
11
|
* @class Repository
|
|
@@ -37,11 +38,16 @@ export class Repository extends TypedEventEmitterClass(AsyncEventEmitter) {
|
|
|
37
38
|
*
|
|
38
39
|
* @param {PartialDTO<T>} input - The input data
|
|
39
40
|
* @param {Repository.CreateOptions} [options] - The options object
|
|
41
|
+
* @returns {Promise<any>} A promise that resolves key value(s) of the created record
|
|
40
42
|
* @throws {Error} if an unknown error occurs while creating the resource
|
|
41
43
|
*/
|
|
42
44
|
createOnly(input, options) {
|
|
43
45
|
return this._execute(async (connection) => {
|
|
44
|
-
await this._create(input, { ...options, connection, returning:
|
|
46
|
+
const r = await this._create(input, { ...options, connection, returning: true });
|
|
47
|
+
const primaryIndex = EntityMetadata.getPrimaryIndex(this.entity);
|
|
48
|
+
if (!primaryIndex || primaryIndex.columns.length > 1)
|
|
49
|
+
return r;
|
|
50
|
+
return r[primaryIndex.columns[0]];
|
|
45
51
|
}, options);
|
|
46
52
|
}
|
|
47
53
|
/**
|
package/package.json
CHANGED
|
@@ -1,48 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/connect",
|
|
3
3
|
"description": "Multi-dialect database connection framework written with TypeScript",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.18.0",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"compile": "tsc",
|
|
9
|
-
"prebuild": "npm run lint && npm run clean",
|
|
10
|
-
"build": "npm run build:cjs && npm run build:esm",
|
|
11
|
-
"build:cjs": "tsc -b tsconfig-build-cjs.json && cp ../../support/package.cjs.json ../../build/connect/cjs/package.json",
|
|
12
|
-
"build:esm": "tsc -b tsconfig-build-esm.json && cp ../../support/package.esm.json ../../build/connect/esm/package.json",
|
|
13
|
-
"postbuild": "cp README.md package.json ../../LICENSE ../../build/connect",
|
|
14
|
-
"lint": "eslint . --max-warnings=0",
|
|
15
|
-
"lint:fix": "eslint . --max-warnings=0 --fix",
|
|
16
|
-
"format": "prettier . --write --log-level=warn",
|
|
17
|
-
"test": "jest",
|
|
18
|
-
"cover": "jest --collect-coverage",
|
|
19
|
-
"clean": "npm run clean:src | npm run clean:dist | npm run clean:cover",
|
|
20
|
-
"clean:src": "ts-cleanup -s src --all",
|
|
21
|
-
"clean:dist": "rimraf ../../build/connectt",
|
|
22
|
-
"clean:cover": "rimraf ../../coverage/connect"
|
|
23
|
-
},
|
|
24
7
|
"dependencies": {
|
|
25
|
-
"debug": "^4.3.
|
|
8
|
+
"debug": "^4.3.7",
|
|
26
9
|
"doublylinked": "^2.5.4",
|
|
27
|
-
"fast-tokenizer": "^1.
|
|
28
|
-
"lightning-pool": "^4.
|
|
10
|
+
"fast-tokenizer": "^1.7.0",
|
|
11
|
+
"lightning-pool": "^4.8.0",
|
|
29
12
|
"lodash": "^4.17.21",
|
|
30
|
-
"power-tasks": "^1.
|
|
13
|
+
"power-tasks": "^1.11.0",
|
|
31
14
|
"putil-isplainobject": "^1.1.5",
|
|
32
15
|
"putil-merge": "^3.13.0",
|
|
33
16
|
"putil-promisify": "^1.10.1",
|
|
34
17
|
"putil-varhelpers": "^1.6.5",
|
|
35
|
-
"strict-typed-events": "^2.
|
|
18
|
+
"strict-typed-events": "^2.8.0",
|
|
36
19
|
"ts-gems": "^3.5.0",
|
|
37
|
-
"tslib": "^2.
|
|
38
|
-
},
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"@types/debug": "^4.1.12",
|
|
41
|
-
"@types/lodash": "^4.17.7",
|
|
42
|
-
"postgrejs": "^2.18.1"
|
|
20
|
+
"tslib": "^2.7.0"
|
|
43
21
|
},
|
|
44
22
|
"peerDependencies": {
|
|
45
|
-
"@sqb/builder": "^4.
|
|
23
|
+
"@sqb/builder": "^4.18.0",
|
|
46
24
|
"reflect-metadata": "^0.2.2"
|
|
47
25
|
},
|
|
48
26
|
"type": "module",
|
|
@@ -53,7 +31,7 @@
|
|
|
53
31
|
"default": "./esm/index.js"
|
|
54
32
|
},
|
|
55
33
|
"require": {
|
|
56
|
-
"types": "./types/index.d.
|
|
34
|
+
"types": "./types/index.d.cts",
|
|
57
35
|
"default": "./cjs/index.js"
|
|
58
36
|
},
|
|
59
37
|
"default": "./esm/index.js"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
export * from './client/adapter.js';
|
|
3
|
+
export * from './client/cursor.js';
|
|
4
|
+
export * from './client/extensions.js';
|
|
5
|
+
export * from './client/sqb-client.js';
|
|
6
|
+
export * from './client/sqb-connection.js';
|
|
7
|
+
export * from './client/types.js';
|
|
8
|
+
export * from './orm/backward.js';
|
|
9
|
+
export * from './orm/base-entity.js';
|
|
10
|
+
export * from './orm/decorators/column.decorator.js';
|
|
11
|
+
export * from './orm/decorators/embedded.decorator.js';
|
|
12
|
+
export * from './orm/decorators/entity.decorator.js';
|
|
13
|
+
export * from './orm/decorators/events.decorator.js';
|
|
14
|
+
export * from './orm/decorators/foreignkey.decorator.js';
|
|
15
|
+
export * from './orm/decorators/index.decorator.js';
|
|
16
|
+
export * from './orm/decorators/link.decorator.js';
|
|
17
|
+
export * from './orm/decorators/primarykey.decorator.js';
|
|
18
|
+
export * from './orm/decorators/transform.decorator.js';
|
|
19
|
+
export * from './orm/model/association.js';
|
|
20
|
+
export * from './orm/model/association-field-metadata.js';
|
|
21
|
+
export * from './orm/model/association-node.js';
|
|
22
|
+
export * from './orm/model/column-field-metadata.js';
|
|
23
|
+
export * from './orm/model/embedded-field-metadata.js';
|
|
24
|
+
export * from './orm/model/entity-metadata.js';
|
|
25
|
+
export * from './orm/model/field-metadata.js';
|
|
26
|
+
export * from './orm/model/index-metadata.js';
|
|
27
|
+
export * from './orm/model/link-chain.js';
|
|
28
|
+
export * from './orm/orm.const.js';
|
|
29
|
+
export * from './orm/orm.type.js';
|
|
30
|
+
export * from './orm/repository.class.js';
|
|
31
|
+
export { isAssociationField, isColumnField, isEmbeddedField, isEntityClass } from './orm/util/orm.helper.js';
|
|
32
|
+
export * from './orm/util/parse-fields-projection.js';
|
|
@@ -80,9 +80,10 @@ export declare class Repository<T> extends Repository_base {
|
|
|
80
80
|
*
|
|
81
81
|
* @param {PartialDTO<T>} input - The input data
|
|
82
82
|
* @param {Repository.CreateOptions} [options] - The options object
|
|
83
|
+
* @returns {Promise<any>} A promise that resolves key value(s) of the created record
|
|
83
84
|
* @throws {Error} if an unknown error occurs while creating the resource
|
|
84
85
|
*/
|
|
85
|
-
createOnly(input: PartialDTO<T>, options?: StrictOmit<Repository.CreateOptions, keyof Projection>): Promise<
|
|
86
|
+
createOnly(input: PartialDTO<T>, options?: StrictOmit<Repository.CreateOptions, keyof Projection>): Promise<any>;
|
|
86
87
|
/**
|
|
87
88
|
* Returns the count of records based on the provided options
|
|
88
89
|
*
|