@itrocks/mysql-maintainer 0.1.1 → 0.2.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.
- package/cjs/mysql-maintainer.d.ts +1 -1
- package/cjs/mysql-maintainer.js +1 -1
- package/cjs/mysql.d.ts +8 -7
- package/cjs/mysql.js +7 -0
- package/esm/mysql-maintainer.d.ts +1 -1
- package/esm/mysql-maintainer.js +1 -1
- package/esm/mysql.d.ts +8 -7
- package/esm/mysql.js +7 -0
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ export declare class MysqlMaintainer {
|
|
|
12
12
|
createImplicitTable(type1: ObjectOrType, type2: ObjectOrType): Promise<boolean>;
|
|
13
13
|
createTable(type: Type): Promise<boolean>;
|
|
14
14
|
implicitTableName(type1: ObjectOrType, type2: ObjectOrType): string;
|
|
15
|
-
manageError(error: SqlError, context: Context,
|
|
15
|
+
manageError(error: SqlError, context: Context, _sql: string | QueryOptions, _values: any[]): Promise<boolean>;
|
|
16
16
|
updateContextTables(context: Context, tableName?: string): Promise<boolean>;
|
|
17
17
|
updateTable(type: Type): Promise<boolean>;
|
|
18
18
|
}
|
package/cjs/mysql-maintainer.js
CHANGED
|
@@ -51,7 +51,7 @@ CONSTRAINT \`${joinTable}.${table2}_id\` FOREIGN KEY (${table2}_id) REFERENCES \
|
|
|
51
51
|
}
|
|
52
52
|
return (0, mysql_1.joinTableName)(table1, table2);
|
|
53
53
|
}
|
|
54
|
-
async manageError(error, context,
|
|
54
|
+
async manageError(error, context, _sql, _values) {
|
|
55
55
|
if (exports.DEBUG)
|
|
56
56
|
console.log('MAINTAINER: manageError', error);
|
|
57
57
|
switch (error.code) {
|
package/cjs/mysql.d.ts
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { KeyOf } from '@itrocks/class-type';
|
|
2
1
|
import { ObjectOrType } from '@itrocks/class-type';
|
|
3
2
|
import { Type } from '@itrocks/class-type';
|
|
4
|
-
import { Options } from '@itrocks/storage';
|
|
5
3
|
import { Mysql as M } from '@itrocks/mysql';
|
|
6
4
|
import { Entity } from '@itrocks/storage';
|
|
7
5
|
import { Identifier } from '@itrocks/storage';
|
|
6
|
+
import { MayEntity } from '@itrocks/storage';
|
|
7
|
+
import { Options } from '@itrocks/storage';
|
|
8
8
|
import { SearchType } from '@itrocks/storage';
|
|
9
9
|
import { ContextualConnection } from './contextual-connection';
|
|
10
10
|
export declare class Mysql extends M {
|
|
11
11
|
connection?: ContextualConnection;
|
|
12
12
|
connect(): Promise<ContextualConnection>;
|
|
13
|
-
deleteId<T extends object>(type: ObjectOrType<T>, id: any, property?:
|
|
14
|
-
deleteRelatedId<T extends Entity>(object: T, property:
|
|
13
|
+
deleteId<T extends object>(type: ObjectOrType<T>, id: any, property?: keyof Entity<T>): Promise<void>;
|
|
14
|
+
deleteRelatedId<T extends Entity>(object: T, property: keyof T, id: Identifier): Promise<void>;
|
|
15
15
|
insert<T extends object>(object: T): Promise<Entity<T>>;
|
|
16
|
-
insertRelatedId<T extends Entity>(object: T, property:
|
|
16
|
+
insertRelatedId<T extends Entity>(object: T, property: keyof T, id: Identifier): Promise<void>;
|
|
17
17
|
read<T extends object>(type: Type<T>, id: Identifier): Promise<Entity<T>>;
|
|
18
|
-
readCollection<T extends object, PT extends object>(object: Entity<T>, property:
|
|
18
|
+
readCollection<T extends object, PT extends object>(object: Entity<T>, property: keyof T, type?: Type<PT>): Promise<Awaited<PT & {
|
|
19
19
|
id: Identifier;
|
|
20
20
|
}>[]>;
|
|
21
|
-
readCollectionIds<T extends object, PT extends object>(object: Entity<T>, property:
|
|
21
|
+
readCollectionIds<T extends object, PT extends object>(object: Entity<T>, property: keyof T, type?: Type<PT>): Promise<Identifier[]>;
|
|
22
22
|
readMultiple<T extends object>(type: Type<T>, ids: Identifier[]): Promise<Entity<T>[]>;
|
|
23
|
+
save<T extends object>(object: MayEntity<T>): Promise<Entity<T>>;
|
|
23
24
|
search<T extends object>(type: Type<T>, search?: SearchType<T>, options?: Options): Promise<Entity<T>[]>;
|
|
24
25
|
update<T extends object>(object: Entity<T>): Promise<Entity<T>>;
|
|
25
26
|
}
|
package/cjs/mysql.js
CHANGED
|
@@ -66,6 +66,13 @@ class Mysql extends mysql_1.Mysql {
|
|
|
66
66
|
contexts.pop();
|
|
67
67
|
return result;
|
|
68
68
|
}
|
|
69
|
+
async save(object) {
|
|
70
|
+
const contexts = (this.connection ?? await this.connect()).contexts;
|
|
71
|
+
contexts.push(object);
|
|
72
|
+
const result = await super.save(object);
|
|
73
|
+
contexts.pop();
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
69
76
|
async search(type, search = {}, options) {
|
|
70
77
|
const contexts = (this.connection ?? await this.connect()).contexts;
|
|
71
78
|
contexts.push(type);
|
|
@@ -12,7 +12,7 @@ export declare class MysqlMaintainer {
|
|
|
12
12
|
createImplicitTable(type1: ObjectOrType, type2: ObjectOrType): Promise<boolean>;
|
|
13
13
|
createTable(type: Type): Promise<boolean>;
|
|
14
14
|
implicitTableName(type1: ObjectOrType, type2: ObjectOrType): string;
|
|
15
|
-
manageError(error: SqlError, context: Context,
|
|
15
|
+
manageError(error: SqlError, context: Context, _sql: string | QueryOptions, _values: any[]): Promise<boolean>;
|
|
16
16
|
updateContextTables(context: Context, tableName?: string): Promise<boolean>;
|
|
17
17
|
updateTable(type: Type): Promise<boolean>;
|
|
18
18
|
}
|
package/esm/mysql-maintainer.js
CHANGED
|
@@ -47,7 +47,7 @@ CONSTRAINT \`${joinTable}.${table2}_id\` FOREIGN KEY (${table2}_id) REFERENCES \
|
|
|
47
47
|
}
|
|
48
48
|
return joinTableName(table1, table2);
|
|
49
49
|
}
|
|
50
|
-
async manageError(error, context,
|
|
50
|
+
async manageError(error, context, _sql, _values) {
|
|
51
51
|
if (DEBUG)
|
|
52
52
|
console.log('MAINTAINER: manageError', error);
|
|
53
53
|
switch (error.code) {
|
package/esm/mysql.d.ts
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { KeyOf } from '@itrocks/class-type';
|
|
2
1
|
import { ObjectOrType } from '@itrocks/class-type';
|
|
3
2
|
import { Type } from '@itrocks/class-type';
|
|
4
|
-
import { Options } from '@itrocks/storage';
|
|
5
3
|
import { Mysql as M } from '@itrocks/mysql';
|
|
6
4
|
import { Entity } from '@itrocks/storage';
|
|
7
5
|
import { Identifier } from '@itrocks/storage';
|
|
6
|
+
import { MayEntity } from '@itrocks/storage';
|
|
7
|
+
import { Options } from '@itrocks/storage';
|
|
8
8
|
import { SearchType } from '@itrocks/storage';
|
|
9
9
|
import { ContextualConnection } from './contextual-connection';
|
|
10
10
|
export declare class Mysql extends M {
|
|
11
11
|
connection?: ContextualConnection;
|
|
12
12
|
connect(): Promise<ContextualConnection>;
|
|
13
|
-
deleteId<T extends object>(type: ObjectOrType<T>, id: any, property?:
|
|
14
|
-
deleteRelatedId<T extends Entity>(object: T, property:
|
|
13
|
+
deleteId<T extends object>(type: ObjectOrType<T>, id: any, property?: keyof Entity<T>): Promise<void>;
|
|
14
|
+
deleteRelatedId<T extends Entity>(object: T, property: keyof T, id: Identifier): Promise<void>;
|
|
15
15
|
insert<T extends object>(object: T): Promise<Entity<T>>;
|
|
16
|
-
insertRelatedId<T extends Entity>(object: T, property:
|
|
16
|
+
insertRelatedId<T extends Entity>(object: T, property: keyof T, id: Identifier): Promise<void>;
|
|
17
17
|
read<T extends object>(type: Type<T>, id: Identifier): Promise<Entity<T>>;
|
|
18
|
-
readCollection<T extends object, PT extends object>(object: Entity<T>, property:
|
|
18
|
+
readCollection<T extends object, PT extends object>(object: Entity<T>, property: keyof T, type?: Type<PT>): Promise<Awaited<PT & {
|
|
19
19
|
id: Identifier;
|
|
20
20
|
}>[]>;
|
|
21
|
-
readCollectionIds<T extends object, PT extends object>(object: Entity<T>, property:
|
|
21
|
+
readCollectionIds<T extends object, PT extends object>(object: Entity<T>, property: keyof T, type?: Type<PT>): Promise<Identifier[]>;
|
|
22
22
|
readMultiple<T extends object>(type: Type<T>, ids: Identifier[]): Promise<Entity<T>[]>;
|
|
23
|
+
save<T extends object>(object: MayEntity<T>): Promise<Entity<T>>;
|
|
23
24
|
search<T extends object>(type: Type<T>, search?: SearchType<T>, options?: Options): Promise<Entity<T>[]>;
|
|
24
25
|
update<T extends object>(object: Entity<T>): Promise<Entity<T>>;
|
|
25
26
|
}
|
package/esm/mysql.js
CHANGED
|
@@ -63,6 +63,13 @@ export class Mysql extends M {
|
|
|
63
63
|
contexts.pop();
|
|
64
64
|
return result;
|
|
65
65
|
}
|
|
66
|
+
async save(object) {
|
|
67
|
+
const contexts = (this.connection ?? await this.connect()).contexts;
|
|
68
|
+
contexts.push(object);
|
|
69
|
+
const result = await super.save(object);
|
|
70
|
+
contexts.pop();
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
66
73
|
async search(type, search = {}, options) {
|
|
67
74
|
const contexts = (this.connection ?? await this.connect()).contexts;
|
|
68
75
|
contexts.push(type);
|
package/package.json
CHANGED