vona-module-a-orm 5.0.37
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/LICENSE +21 -0
- package/cli/databaseDialect/boilerplate/{{sceneName}}.{{beanName}}.ts_ +4 -0
- package/cli/entity/boilerplate/{{beanName}}.ts_ +7 -0
- package/cli/entity/metadata/generate.ts +52 -0
- package/cli/model/boilerplate/{{beanName}}.ts_ +8 -0
- package/cli/model/metadata/generate.ts +285 -0
- package/dist/.metadata/index.d.ts +246 -0
- package/dist/.metadata/this.d.ts +2 -0
- package/dist/bean/aopMethod.transaction.d.ts +9 -0
- package/dist/bean/bean.database.d.ts +12 -0
- package/dist/bean/bean.databaseDialectBase.d.ts +20 -0
- package/dist/bean/bean.model/bean.model_cache.d.ts +56 -0
- package/dist/bean/bean.model/bean.model_crud.d.ts +13 -0
- package/dist/bean/bean.model/bean.model_crud_inner.d.ts +15 -0
- package/dist/bean/bean.model/bean.model_crud_table.d.ts +13 -0
- package/dist/bean/bean.model/bean.model_knex.d.ts +15 -0
- package/dist/bean/bean.model/bean.model_meta.d.ts +40 -0
- package/dist/bean/bean.model/bean.model_utils.d.ts +39 -0
- package/dist/bean/bean.model/bean.model_view.d.ts +14 -0
- package/dist/bean/bean.model.d.ts +3 -0
- package/dist/bean/bean.modelBase.d.ts +3 -0
- package/dist/bean/broadcast.columnsClear.d.ts +10 -0
- package/dist/bean/broadcast.databaseClientReload.d.ts +12 -0
- package/dist/bean/event.clientNameReal.d.ts +6 -0
- package/dist/bean/event.columnsClear.d.ts +9 -0
- package/dist/bean/event.databaseClientReload.d.ts +11 -0
- package/dist/bean/schedule.softDeletionPrune.d.ts +6 -0
- package/dist/common/buildWhere.d.ts +4 -0
- package/dist/common/checkWhere.d.ts +1 -0
- package/dist/common/index.d.ts +3 -0
- package/dist/common/utils.d.ts +10 -0
- package/dist/config/config.d.ts +72 -0
- package/dist/config/errors.d.ts +3 -0
- package/dist/config/locale/en-us.d.ts +9 -0
- package/dist/config/locale/zh-cn.d.ts +9 -0
- package/dist/extend/index.d.ts +4 -0
- package/dist/extend/schemaBuilder.d.ts +13 -0
- package/dist/extend/tableBuilder.d.ts +22 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4085 -0
- package/dist/lib/columns.d.ts +9 -0
- package/dist/lib/database.d.ts +6 -0
- package/dist/lib/databaseDialect.d.ts +1 -0
- package/dist/lib/dto/dto.d.ts +12 -0
- package/dist/lib/dto/dtoAggregate.d.ts +8 -0
- package/dist/lib/dto/dtoCreate.d.ts +5 -0
- package/dist/lib/dto/dtoGet.d.ts +8 -0
- package/dist/lib/dto/dtoGroup.d.ts +8 -0
- package/dist/lib/dto/dtoMutate.d.ts +8 -0
- package/dist/lib/dto/dtoUpdate.d.ts +5 -0
- package/dist/lib/dto/index.d.ts +1 -0
- package/dist/lib/entity.d.ts +3 -0
- package/dist/lib/index.d.ts +10 -0
- package/dist/lib/model.d.ts +2 -0
- package/dist/lib/modelCacheBase.d.ts +20 -0
- package/dist/lib/relations.d.ts +15 -0
- package/dist/lib/relationsDynamic.d.ts +15 -0
- package/dist/lib/relationsMutate.d.ts +14 -0
- package/dist/lib/relationsStatic.d.ts +9 -0
- package/dist/main.d.ts +9 -0
- package/dist/service/cacheEntity_.d.ts +10 -0
- package/dist/service/cacheQuery_.d.ts +7 -0
- package/dist/service/columnsCache_.d.ts +22 -0
- package/dist/service/columns_.d.ts +13 -0
- package/dist/service/database.d.ts +17 -0
- package/dist/service/databaseAsyncLocalStorage_.d.ts +10 -0
- package/dist/service/databaseClient_.d.ts +30 -0
- package/dist/service/db_.d.ts +26 -0
- package/dist/service/entityResolver_.d.ts +9 -0
- package/dist/service/modelResolver_.d.ts +8 -0
- package/dist/service/relations_.d.ts +19 -0
- package/dist/service/transactionAsyncLocalStorage_.d.ts +10 -0
- package/dist/service/transactionConsistency/342/200/214_.d.ts +10 -0
- package/dist/service/transactionFiber_.d.ts +13 -0
- package/dist/service/transactionState_.d.ts +11 -0
- package/dist/service/transaction_.d.ts +18 -0
- package/dist/types/columns.d.ts +6 -0
- package/dist/types/config.d.ts +14 -0
- package/dist/types/database.d.ts +47 -0
- package/dist/types/dialect.d.ts +6 -0
- package/dist/types/dto/dtoAggregate.d.ts +2 -0
- package/dist/types/dto/dtoGet.d.ts +12 -0
- package/dist/types/dto/dtoGroup.d.ts +2 -0
- package/dist/types/dto/dtoMutate.d.ts +14 -0
- package/dist/types/dto/index.d.ts +4 -0
- package/dist/types/entity.d.ts +15 -0
- package/dist/types/entityBase.d.ts +5 -0
- package/dist/types/entityBaseEmpty.d.ts +2 -0
- package/dist/types/entityBaseInner.d.ts +7 -0
- package/dist/types/entityBaseSimple.d.ts +4 -0
- package/dist/types/extra.d.ts +11 -0
- package/dist/types/index.d.ts +30 -0
- package/dist/types/logger.d.ts +7 -0
- package/dist/types/model.d.ts +79 -0
- package/dist/types/modelAggr.d.ts +26 -0
- package/dist/types/modelCount.d.ts +15 -0
- package/dist/types/modelGeneral.d.ts +23 -0
- package/dist/types/modelGroup.d.ts +23 -0
- package/dist/types/modelWhere.d.ts +86 -0
- package/dist/types/onion/databaseDialect.d.ts +17 -0
- package/dist/types/onion/entity.d.ts +26 -0
- package/dist/types/onion/index.d.ts +4 -0
- package/dist/types/onion/model.d.ts +55 -0
- package/dist/types/onion/table.d.ts +2 -0
- package/dist/types/relations.d.ts +102 -0
- package/dist/types/relationsAggr.d.ts +16 -0
- package/dist/types/relationsColumns.d.ts +45 -0
- package/dist/types/relationsDef.d.ts +59 -0
- package/dist/types/relationsDefDynamic.d.ts +56 -0
- package/dist/types/relationsDefMutate.d.ts +9 -0
- package/dist/types/relationsGroup.d.ts +21 -0
- package/dist/types/relationsMutate.d.ts +25 -0
- package/dist/types/relationsTables.d.ts +15 -0
- package/dist/types/tableIdentity.d.ts +1 -0
- package/dist/types/transaction.d.ts +18 -0
- package/package.json +74 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016-present Vona
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IDecoratorEntityOptions } from 'vona-module-a-orm';
|
|
2
|
+
import { Entity, EntityBase } from 'vona-module-a-orm';
|
|
3
|
+
|
|
4
|
+
export interface IEntityOptions<%=argv.beanNameCapitalize%> extends IDecoratorEntityOptions {}
|
|
5
|
+
|
|
6
|
+
@Entity<IEntityOptions<%=argv.beanNameCapitalize%>>('<%=argv.moduleResourceName%>')
|
|
7
|
+
export class Entity<%=argv.beanNameCapitalize%> extends EntityBase {}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { IMetadataCustomGenerateOptions } from '@cabloy/cli';
|
|
2
|
+
import { toUpperCaseFirstChar } from '@cabloy/word-utils';
|
|
3
|
+
|
|
4
|
+
export default async function (options: IMetadataCustomGenerateOptions): Promise<string> {
|
|
5
|
+
const { sceneName, moduleName, globFiles } = options;
|
|
6
|
+
const contentColumns: string[] = [];
|
|
7
|
+
const contentEntityMetas: string[] = [];
|
|
8
|
+
const contentRecords: string[] = [];
|
|
9
|
+
const contentFields: string[] = [];
|
|
10
|
+
for (const globFile of globFiles) {
|
|
11
|
+
const { className, beanName, fileContent } = globFile;
|
|
12
|
+
const opionsName = `IEntityOptions${toUpperCaseFirstChar(beanName)}`;
|
|
13
|
+
const tableName = __parseTableName(fileContent);
|
|
14
|
+
contentColumns.push(`export type ${className}TableName = '${tableName}';`);
|
|
15
|
+
contentEntityMetas.push(`export type ${className}Meta=TypeEntityMeta<${className},${className}TableName>;`);
|
|
16
|
+
const contentRecordItem = `'${tableName}': never;`;
|
|
17
|
+
if (!contentRecords.includes(contentRecordItem)) {
|
|
18
|
+
contentRecords.push(contentRecordItem);
|
|
19
|
+
}
|
|
20
|
+
contentFields.push(`
|
|
21
|
+
export interface ${opionsName} {
|
|
22
|
+
fields?: TypeEntityOptionsFields<${className}, ${opionsName}[TypeSymbolKeyFieldsMore]>;
|
|
23
|
+
}`);
|
|
24
|
+
}
|
|
25
|
+
if (contentColumns.length === 0 && contentEntityMetas.length === 0 && contentRecords.length === 0 && contentFields.length === 0) return '';
|
|
26
|
+
// combine
|
|
27
|
+
const content = `/** ${sceneName}: begin */
|
|
28
|
+
${contentColumns.join('\n')}
|
|
29
|
+
${contentEntityMetas.join('\n')}
|
|
30
|
+
declare module 'vona-module-a-orm' {
|
|
31
|
+
export interface ITableRecord {
|
|
32
|
+
${contentRecords.join('\n')}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
declare module 'vona-module-${moduleName}' {
|
|
36
|
+
${contentFields.join('\n')}
|
|
37
|
+
}
|
|
38
|
+
/** ${sceneName}: end */
|
|
39
|
+
`;
|
|
40
|
+
return content;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function __parseTableName(fileContent: string): string | false {
|
|
44
|
+
let matched = fileContent.match(/@Entity<.*?>\(\{[\s\S]*?table: ('[^']*')[\s\S]*?\}[\s\S]*?\)\s*export class/);
|
|
45
|
+
if (!matched) {
|
|
46
|
+
matched = fileContent.match(/@Entity<.*?>\(([^)]*)\)/);
|
|
47
|
+
}
|
|
48
|
+
if (!matched) return false;
|
|
49
|
+
const tableName = matched[1];
|
|
50
|
+
if (tableName === '') return '';
|
|
51
|
+
return tableName.split(',')[0].replaceAll("'", '');
|
|
52
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IDecoratorModelOptions } from 'vona-module-a-orm';
|
|
2
|
+
import { BeanModelBase, Model } from 'vona-module-a-orm';
|
|
3
|
+
import { Entity<%=argv.beanNameCapitalize%> } from '../entity/<%=argv.beanName%>.ts';
|
|
4
|
+
|
|
5
|
+
export interface IModelOptions<%=argv.beanNameCapitalize%> extends IDecoratorModelOptions<Entity<%=argv.beanNameCapitalize%>> {}
|
|
6
|
+
|
|
7
|
+
@Model<IModelOptions<%=argv.beanNameCapitalize%>>({ entity: Entity<%=argv.beanNameCapitalize%> })
|
|
8
|
+
export class Model<%=argv.beanNameCapitalize%> extends BeanModelBase<Entity<%=argv.beanNameCapitalize%>> {}
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import type { IMetadataCustomGenerateOptions } from '@cabloy/cli';
|
|
2
|
+
import { types as t } from '@babel/core';
|
|
3
|
+
|
|
4
|
+
export default async function (options: IMetadataCustomGenerateOptions): Promise<string> {
|
|
5
|
+
const { sceneName, moduleName, globFiles, cli } = options;
|
|
6
|
+
const contentRelations: string[] = [];
|
|
7
|
+
const contentRecords: string[] = [];
|
|
8
|
+
const contentModels: string[] = [];
|
|
9
|
+
// const contentModelsOptions: string[] = [];
|
|
10
|
+
for (const globFile of globFiles) {
|
|
11
|
+
const { className, beanName, fileContent, beanNameCapitalize } = globFile;
|
|
12
|
+
const ast = cli.helper.gogocode(fileContent);
|
|
13
|
+
const astNodes = ast.find(`@Model<$$$0>({$$$1})export class ${className} extends $$$2 {}`).match.$$$1;
|
|
14
|
+
const entityName = __parseEntityName(__getAstNode(astNodes as any, 'entity'));
|
|
15
|
+
const relations = __parseRelations(__getAstNode(astNodes as any, 'relations'));
|
|
16
|
+
const entityMetaName = `${entityName}Meta`;
|
|
17
|
+
const opionsName = `IModelOptions${beanNameCapitalize}`;
|
|
18
|
+
if (relations && relations.length > 0) {
|
|
19
|
+
contentRelations.push(`export interface ${opionsName} {
|
|
20
|
+
relations: {
|
|
21
|
+
${relations.join('\n')}
|
|
22
|
+
};
|
|
23
|
+
}`);
|
|
24
|
+
}
|
|
25
|
+
contentRecords.push(`export interface ${className} {
|
|
26
|
+
[SymbolKeyEntity]: ${entityName};
|
|
27
|
+
[SymbolKeyEntityMeta]: ${entityMetaName};
|
|
28
|
+
[SymbolKeyModelOptions]: ${opionsName};
|
|
29
|
+
get<T extends IModelGetOptions<${entityName},${className}>>(where: TypeModelWhere<${entityName}>, options?: T): Promise<TypeModelRelationResult<${entityName}, ${className}, T> | undefined>;
|
|
30
|
+
mget<T extends IModelGetOptions<${entityName},${className}>>(ids: TableIdentity[], options?: T): Promise<TypeModelRelationResult<${entityName}, ${className}, T>[]>;
|
|
31
|
+
select<T extends IModelSelectParams<${entityName},${className},ModelJoins>, ModelJoins extends TypeModelsClassLikeGeneral | undefined = undefined>(params?: T, options?: IModelMethodOptions, modelJoins?: ModelJoins): Promise<TypeModelRelationResult<${entityName}, ${className}, T>[]>;
|
|
32
|
+
insert<T extends IModelInsertOptions<${entityName},${className}>>(data?: TypeModelMutateRelationData<${entityName},${className}, T>, options?: T): Promise<Required<TypeModelMutateRelationData<${entityName},${className}, T>>>;
|
|
33
|
+
insertBulk<T extends IModelInsertOptions<${entityName},${className}>>(items: TypeModelMutateRelationData<${entityName},${className}, T>[], options?: T): Promise<Required<TypeModelMutateRelationData<${entityName},${className}, T>>[]>;
|
|
34
|
+
update<T extends IModelUpdateOptions<${entityName},${className}>>(data: TypeModelMutateRelationData<${entityName},${className}, T>, options?: T): Promise<TypeModelMutateRelationData<${entityName},${className}, T>>;
|
|
35
|
+
updateBulk<T extends IModelUpdateOptions<${entityName},${className}>>(items: TypeModelMutateRelationData<${entityName},${className}, T>[], options?: T): Promise<TypeModelMutateRelationData<${entityName},${className}, T>[]>;
|
|
36
|
+
delete<T extends IModelDeleteOptions<${entityName},${className}>>(where?: TypeModelWhere<${entityName}>, options?: T): Promise<void>;
|
|
37
|
+
deleteBulk<T extends IModelDeleteOptions<${entityName},${className}>>(ids: TableIdentity[], options?: T): Promise<void>;
|
|
38
|
+
mutate<T extends IModelMutateOptions<${entityName},${className}>>(data?: TypeModelMutateRelationData<${entityName},${className}, T>, options?: T): Promise<TypeModelMutateRelationData<${entityName},${className}, T>>;
|
|
39
|
+
mutateBulk<T extends IModelMutateOptions<${entityName},${className}>>(items: TypeModelMutateRelationData<${entityName},${className}, T>[], options?: T): Promise<TypeModelMutateRelationData<${entityName},${className}, T>[]>;
|
|
40
|
+
count<T extends IModelSelectCountParams<${entityName},${className},ModelJoins>, ModelJoins extends TypeModelsClassLikeGeneral | undefined = undefined>(params?: T, options?: IModelMethodOptions, modelJoins?: ModelJoins): Promise<BigNumber | undefined>;
|
|
41
|
+
aggregate<T extends IModelSelectAggrParams<${entityName},${className},ModelJoins>, ModelJoins extends TypeModelsClassLikeGeneral | undefined = undefined>(params?: T, options?: IModelMethodOptions, modelJoins?: ModelJoins): Promise<TypeModelAggrRelationResult<T>>;
|
|
42
|
+
group<T extends IModelSelectGroupParams<${entityName},${className},ModelJoins>, ModelJoins extends TypeModelsClassLikeGeneral | undefined = undefined>(params?: T, options?: IModelMethodOptions, modelJoins?: ModelJoins): Promise<TypeModelGroupRelationResult<${entityName}, T>[]>;
|
|
43
|
+
}`);
|
|
44
|
+
contentModels.push(`'${moduleName}:${beanName}': ${className};`);
|
|
45
|
+
// only override cache.keyAux which not enough
|
|
46
|
+
// contentModelsOptions.push(`export interface ${opionsName} {
|
|
47
|
+
// cache?: {
|
|
48
|
+
// keyAux?: keyof ${entityName};
|
|
49
|
+
// };
|
|
50
|
+
// }`);
|
|
51
|
+
}
|
|
52
|
+
if (contentRelations.length === 0 && contentRecords.length === 0 && contentModels.length === 0) return '';
|
|
53
|
+
// combine
|
|
54
|
+
const content = `/** ${sceneName}: begin */
|
|
55
|
+
import type { IModelGetOptions, IModelMethodOptions, IModelSelectParams, TableIdentity, TypeModelRelationResult, TypeModelWhere, IModelInsertOptions, TypeModelMutateRelationData, IModelDeleteOptions, IModelUpdateOptions, IModelMutateOptions, IModelSelectCountParams, IModelSelectAggrParams, TypeModelAggrRelationResult, IModelSelectGroupParams, TypeModelGroupRelationResult } from 'vona-module-a-orm';
|
|
56
|
+
import { SymbolKeyEntity, SymbolKeyEntityMeta, SymbolKeyModelOptions } from 'vona-module-a-orm';
|
|
57
|
+
declare module 'vona-module-${moduleName}' {
|
|
58
|
+
${contentRelations.join('\n')}
|
|
59
|
+
${contentRecords.join('\n')}
|
|
60
|
+
}
|
|
61
|
+
declare module 'vona-module-a-orm' {
|
|
62
|
+
export interface IModelClassRecord {
|
|
63
|
+
${contentModels.join('\n')}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** ${sceneName}: end */
|
|
67
|
+
`;
|
|
68
|
+
return content;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function __getAstNode(astNodes: Array<t.ObjectProperty>, name: string) {
|
|
72
|
+
return astNodes.find(node => (node.key as t.Identifier).name === name) as t.ObjectProperty;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function __parseEntityName(node: t.ObjectProperty): string {
|
|
76
|
+
return (node.value as t.Identifier).name;
|
|
77
|
+
// const matched = fileContent.match(/@Model<.*?>\(\{[\s\S]*?entity: (Entity\S+)[\s\S]*?\}[\s\S]*?\)\s*export class/);
|
|
78
|
+
// if (!matched) return false;
|
|
79
|
+
// const entityName = matched[1];
|
|
80
|
+
// if (entityName === '') return '';
|
|
81
|
+
// return entityName.split(',')[0];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function __parseRelations(node?: t.ObjectProperty) {
|
|
85
|
+
if (!node) return;
|
|
86
|
+
const relations: string[] = [];
|
|
87
|
+
const nodeRelations = node.value as t.ObjectExpression;
|
|
88
|
+
for (const nodeRelation of nodeRelations.properties) {
|
|
89
|
+
relations.push(__parseRelation(nodeRelation as t.ObjectProperty));
|
|
90
|
+
}
|
|
91
|
+
return relations;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function __parseRelation(nodeRelation: t.ObjectProperty) {
|
|
95
|
+
const relationName = (nodeRelation.key as t.Identifier).name;
|
|
96
|
+
const callExpression = nodeRelation.value as t.CallExpression;
|
|
97
|
+
const relationType = ((callExpression.callee as t.MemberExpression).property as t.Identifier).name;
|
|
98
|
+
const args: t.Node[] = callExpression.arguments;
|
|
99
|
+
// relation
|
|
100
|
+
if (relationType === 'hasOne') {
|
|
101
|
+
return `${relationName}: ${__parseRelationHasOne(args)};`;
|
|
102
|
+
} else if (relationType === 'belongsTo') {
|
|
103
|
+
return `${relationName}: ${__parseRelationBelongsTo(args)};`;
|
|
104
|
+
} else if (relationType === 'hasMany') {
|
|
105
|
+
return `${relationName}: ${__parseRelationHasMany(args)};`;
|
|
106
|
+
} else if (relationType === 'belongsToMany') {
|
|
107
|
+
return `${relationName}: ${__parseRelationBelongsToMany(args)};`;
|
|
108
|
+
}
|
|
109
|
+
return '';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function __parseRelationHasOne(args: t.Node[]) {
|
|
113
|
+
// classModel
|
|
114
|
+
const classModel = __parseRelation_classModel(args[0]);
|
|
115
|
+
// options
|
|
116
|
+
const options = __parseRelation_options(args[2]);
|
|
117
|
+
// combine
|
|
118
|
+
return `IModelRelationHasOne<${classModel}, ${options.autoload}, ${options.columns}>`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function __parseRelationBelongsTo(args: t.Node[]) {
|
|
122
|
+
// classModelSelf
|
|
123
|
+
const classModelSelf = __parseRelation_classModel(args[0]);
|
|
124
|
+
// classModel
|
|
125
|
+
const classModel = __parseRelation_classModel(args[1]);
|
|
126
|
+
// options
|
|
127
|
+
const options = __parseRelation_options(args[3]);
|
|
128
|
+
// combine
|
|
129
|
+
return `IModelRelationBelongsTo<${classModelSelf}, ${classModel}, ${options.autoload}, ${options.columns}>`;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function __parseRelationHasMany(args: t.Node[]) {
|
|
133
|
+
// classModel
|
|
134
|
+
const classModel = __parseRelation_classModel(args[0]);
|
|
135
|
+
// // key
|
|
136
|
+
// const key = __parseRelation_key(args[1]);
|
|
137
|
+
// options
|
|
138
|
+
const options = __parseRelation_options(args[2]);
|
|
139
|
+
// modelJoins
|
|
140
|
+
const modelJoins = __parseRelation_modelJoins(args[3]);
|
|
141
|
+
// combine
|
|
142
|
+
return `IModelRelationHasMany<${classModel}, ${options.autoload}, ${options.columns},${modelJoins},${options.aggrs},${options.groups}>`;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function __parseRelationBelongsToMany(args: t.Node[]) {
|
|
146
|
+
// classModelMiddle
|
|
147
|
+
const classModelMiddle = __parseRelation_classModel(args[0]);
|
|
148
|
+
// classModel
|
|
149
|
+
const classModel = __parseRelation_classModel(args[1]);
|
|
150
|
+
// options
|
|
151
|
+
const options = __parseRelation_options(args[4]);
|
|
152
|
+
// modelJoins
|
|
153
|
+
const modelJoins = __parseRelation_modelJoins(args[5]);
|
|
154
|
+
// combine
|
|
155
|
+
return `IModelRelationBelongsToMany<${classModelMiddle}, ${classModel}, ${options.autoload}, ${options.columns},${modelJoins},${options.aggrs},${options.groups}>`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function __parseRelation_classModel(node: t.Node) {
|
|
159
|
+
if (t.isArrowFunctionExpression(node)) {
|
|
160
|
+
return (node.body as t.Identifier).name;
|
|
161
|
+
} else if (t.isIdentifier(node)) {
|
|
162
|
+
return node.name;
|
|
163
|
+
} else if (t.isStringLiteral(node)) {
|
|
164
|
+
return `'${node.value}'`;
|
|
165
|
+
}
|
|
166
|
+
throw new Error('invalid classModel');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function __parseRelation_key(node: t.Node) {
|
|
170
|
+
if (t.isStringLiteral(node)) {
|
|
171
|
+
return node.value;
|
|
172
|
+
}
|
|
173
|
+
throw new Error('invalid key');
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function __parseRelation_modelJoins(node?: t.Node) {
|
|
177
|
+
if (!node) return 'undefined';
|
|
178
|
+
if (t.isIdentifier(node) && node.name === 'undefined') return 'undefined';
|
|
179
|
+
let modelJoins;
|
|
180
|
+
if (t.isArrayExpression(node)) {
|
|
181
|
+
modelJoins = node.elements.map(item => __parseRelation_classModel(item!));
|
|
182
|
+
} else {
|
|
183
|
+
modelJoins = [__parseRelation_classModel(node)];
|
|
184
|
+
}
|
|
185
|
+
return `[${modelJoins.join(',')}]`;
|
|
186
|
+
// const content = `${modelJoins.join('|')}`;
|
|
187
|
+
// return `${content} | Array<${content}>`;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function __parseRelation_aggrs(node?: t.Node) {
|
|
191
|
+
if (!node) return 'undefined';
|
|
192
|
+
if (t.isIdentifier(node) && node.name === 'undefined') return 'undefined';
|
|
193
|
+
const aggrs = __parseRelation_aggrs_inner(node as t.ObjectExpression);
|
|
194
|
+
return `{ ${aggrs.join(';')} }`;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function __parseRelation_aggrs_inner(node: t.ObjectExpression) {
|
|
198
|
+
const aggrs: string[] = [];
|
|
199
|
+
for (const _nodeProperty of node.properties) {
|
|
200
|
+
const nodeProperty = _nodeProperty as t.ObjectProperty;
|
|
201
|
+
const key = (nodeProperty.key as t.Identifier).name;
|
|
202
|
+
const value = __parseColumns(nodeProperty);
|
|
203
|
+
if (value) {
|
|
204
|
+
aggrs.push(`${key}?: ${__joinColumnsType(value, true)}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return aggrs;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function __parseRelation_options(node: t.Node) {
|
|
211
|
+
const options = __parseRelation_options_inner(node);
|
|
212
|
+
let autoload;
|
|
213
|
+
let columns;
|
|
214
|
+
let groups;
|
|
215
|
+
let aggrs;
|
|
216
|
+
// autoload
|
|
217
|
+
if (options?.autoload) {
|
|
218
|
+
autoload = 'true';
|
|
219
|
+
} else {
|
|
220
|
+
autoload = 'false';
|
|
221
|
+
}
|
|
222
|
+
// groups
|
|
223
|
+
if (!options?.groups) {
|
|
224
|
+
groups = 'undefined';
|
|
225
|
+
} else {
|
|
226
|
+
groups = __joinColumnsType(options?.groups, true);
|
|
227
|
+
}
|
|
228
|
+
// aggrs
|
|
229
|
+
if (!options?.aggrs) {
|
|
230
|
+
aggrs = 'undefined';
|
|
231
|
+
} else {
|
|
232
|
+
aggrs = options?.aggrs;
|
|
233
|
+
}
|
|
234
|
+
// columns
|
|
235
|
+
if (!options?.columns) {
|
|
236
|
+
if (options?.groups) {
|
|
237
|
+
columns = 'undefined';
|
|
238
|
+
} else {
|
|
239
|
+
columns = '\'*\'';
|
|
240
|
+
}
|
|
241
|
+
} else {
|
|
242
|
+
if (options?.columns.includes('*')) {
|
|
243
|
+
columns = '\'*\'';
|
|
244
|
+
} else {
|
|
245
|
+
columns = __joinColumnsType(options?.columns, false);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return { autoload, columns, groups, aggrs };
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function __parseRelation_options_inner(node: t.Node) {
|
|
252
|
+
if (!node) return undefined;
|
|
253
|
+
if (!t.isObjectExpression(node)) throw new Error('invalid options');
|
|
254
|
+
let autoload;
|
|
255
|
+
let columns: string[] | undefined;
|
|
256
|
+
let groups;
|
|
257
|
+
let aggrs;
|
|
258
|
+
for (const _nodeProperty of node.properties) {
|
|
259
|
+
const nodeProperty = _nodeProperty as t.ObjectProperty;
|
|
260
|
+
const key = (nodeProperty.key as t.Identifier).name;
|
|
261
|
+
if (key === 'autoload') {
|
|
262
|
+
autoload = (nodeProperty.value as t.BooleanLiteral).value;
|
|
263
|
+
} else if (key === 'columns') {
|
|
264
|
+
columns = __parseColumns(nodeProperty);
|
|
265
|
+
} else if (key === 'groups') {
|
|
266
|
+
groups = __parseColumns(nodeProperty);
|
|
267
|
+
} else if (key === 'aggrs') {
|
|
268
|
+
aggrs = __parseRelation_aggrs(nodeProperty.value);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return { autoload, columns, groups, aggrs };
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function __parseColumns(node: t.ObjectProperty) {
|
|
275
|
+
if (t.isArrayExpression(node.value)) {
|
|
276
|
+
return node.value.elements.map(item => (item as t.StringLiteral).value);
|
|
277
|
+
} else if (t.isStringLiteral(node.value)) {
|
|
278
|
+
return [node.value.value];
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function __joinColumnsType(columns: string[], withArray: boolean) {
|
|
283
|
+
const temp = columns.map(item => `'${item}'`).join('|');
|
|
284
|
+
return withArray ? `${temp} | Array<${temp}>` : temp;
|
|
285
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/** aopMethod: begin */
|
|
2
|
+
export * from '../bean/aopMethod.transaction.ts';
|
|
3
|
+
import type { IAopMethodOptionsTransaction } from '../bean/aopMethod.transaction.ts';
|
|
4
|
+
import 'vona';
|
|
5
|
+
declare module 'vona-module-a-aspect' {
|
|
6
|
+
interface IAopMethodRecord {
|
|
7
|
+
'a-orm:transaction': IAopMethodOptionsTransaction;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
declare module 'vona-module-a-orm' {
|
|
11
|
+
interface AopMethodTransaction {
|
|
12
|
+
}
|
|
13
|
+
interface AopMethodTransaction {
|
|
14
|
+
get $beanFullName(): 'a-orm.aopMethod.transaction';
|
|
15
|
+
get $onionName(): 'a-orm:transaction';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** aopMethod: end */
|
|
19
|
+
/** bean: begin */
|
|
20
|
+
export * from '../bean/bean.database.ts';
|
|
21
|
+
export * from '../bean/bean.databaseDialectBase.ts';
|
|
22
|
+
export * from '../bean/bean.model.ts';
|
|
23
|
+
export * from '../bean/bean.modelBase.ts';
|
|
24
|
+
import 'vona';
|
|
25
|
+
declare module 'vona' {
|
|
26
|
+
}
|
|
27
|
+
declare module 'vona-module-a-orm' {
|
|
28
|
+
interface BeanDatabase {
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** bean: end */
|
|
32
|
+
/** bean: begin */
|
|
33
|
+
import type { BeanDatabase } from '../bean/bean.database.ts';
|
|
34
|
+
import 'vona';
|
|
35
|
+
declare module 'vona' {
|
|
36
|
+
interface IBeanRecordGlobal {
|
|
37
|
+
'database': BeanDatabase;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/** bean: end */
|
|
41
|
+
/** service: begin */
|
|
42
|
+
export * from '../service/cacheEntity_.ts';
|
|
43
|
+
export * from '../service/cacheQuery_.ts';
|
|
44
|
+
export * from '../service/columnsCache_.ts';
|
|
45
|
+
export * from '../service/columns_.ts';
|
|
46
|
+
export * from '../service/database.ts';
|
|
47
|
+
export * from '../service/databaseAsyncLocalStorage_.ts';
|
|
48
|
+
export * from '../service/databaseClient_.ts';
|
|
49
|
+
export * from '../service/db_.ts';
|
|
50
|
+
export * from '../service/entityResolver_.ts';
|
|
51
|
+
export * from '../service/modelResolver_.ts';
|
|
52
|
+
export * from '../service/relations_.ts';
|
|
53
|
+
export * from '../service/transactionAsyncLocalStorage_.ts';
|
|
54
|
+
export * from '../service/transactionConsistency_.ts';
|
|
55
|
+
export * from '../service/transactionFiber_.ts';
|
|
56
|
+
export * from '../service/transactionState_.ts';
|
|
57
|
+
export * from '../service/transaction_.ts';
|
|
58
|
+
import 'vona';
|
|
59
|
+
declare module 'vona-module-a-bean' {
|
|
60
|
+
interface IServiceRecord {
|
|
61
|
+
'a-orm:database': never;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
declare module 'vona-module-a-orm' {
|
|
65
|
+
interface ServiceDatabase {
|
|
66
|
+
}
|
|
67
|
+
interface ServiceDatabase {
|
|
68
|
+
get $beanFullName(): 'a-orm.service.database';
|
|
69
|
+
get $onionName(): 'a-orm:database';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** service: end */
|
|
73
|
+
/** service: begin */
|
|
74
|
+
import type { ServiceDatabase } from '../service/database.ts';
|
|
75
|
+
export interface IModuleService {
|
|
76
|
+
'database': ServiceDatabase;
|
|
77
|
+
}
|
|
78
|
+
/** service: end */
|
|
79
|
+
/** service: begin */
|
|
80
|
+
import 'vona';
|
|
81
|
+
declare module 'vona' {
|
|
82
|
+
interface IBeanRecordGeneral {
|
|
83
|
+
'a-orm.service.database': ServiceDatabase;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** service: end */
|
|
87
|
+
/** broadcast: begin */
|
|
88
|
+
export * from '../bean/broadcast.columnsClear.ts';
|
|
89
|
+
export * from '../bean/broadcast.databaseClientReload.ts';
|
|
90
|
+
import { type IDecoratorBroadcastOptions } from 'vona-module-a-broadcast';
|
|
91
|
+
declare module 'vona-module-a-broadcast' {
|
|
92
|
+
interface IBroadcastRecord {
|
|
93
|
+
'a-orm:columnsClear': IDecoratorBroadcastOptions;
|
|
94
|
+
'a-orm:databaseClientReload': IDecoratorBroadcastOptions;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
declare module 'vona-module-a-orm' {
|
|
98
|
+
interface BroadcastColumnsClear {
|
|
99
|
+
}
|
|
100
|
+
interface BroadcastColumnsClear {
|
|
101
|
+
get $beanFullName(): 'a-orm.broadcast.columnsClear';
|
|
102
|
+
get $onionName(): 'a-orm:columnsClear';
|
|
103
|
+
}
|
|
104
|
+
interface BroadcastDatabaseClientReload {
|
|
105
|
+
}
|
|
106
|
+
interface BroadcastDatabaseClientReload {
|
|
107
|
+
get $beanFullName(): 'a-orm.broadcast.databaseClientReload';
|
|
108
|
+
get $onionName(): 'a-orm:databaseClientReload';
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** broadcast: end */
|
|
112
|
+
/** broadcast: begin */
|
|
113
|
+
import type { BroadcastColumnsClear } from '../bean/broadcast.columnsClear.ts';
|
|
114
|
+
import type { BroadcastDatabaseClientReload } from '../bean/broadcast.databaseClientReload.ts';
|
|
115
|
+
export interface IModuleBroadcast {
|
|
116
|
+
'columnsClear': BroadcastColumnsClear;
|
|
117
|
+
'databaseClientReload': BroadcastDatabaseClientReload;
|
|
118
|
+
}
|
|
119
|
+
/** broadcast: end */
|
|
120
|
+
/** event: begin */
|
|
121
|
+
export * from '../bean/event.clientNameReal.ts';
|
|
122
|
+
export * from '../bean/event.columnsClear.ts';
|
|
123
|
+
export * from '../bean/event.databaseClientReload.ts';
|
|
124
|
+
import 'vona';
|
|
125
|
+
declare module 'vona' {
|
|
126
|
+
}
|
|
127
|
+
declare module 'vona-module-a-orm' {
|
|
128
|
+
interface EventClientNameReal {
|
|
129
|
+
}
|
|
130
|
+
interface EventClientNameReal {
|
|
131
|
+
get $beanFullName(): 'a-orm.event.clientNameReal';
|
|
132
|
+
get $onionName(): 'a-orm:clientNameReal';
|
|
133
|
+
}
|
|
134
|
+
interface EventColumnsClear {
|
|
135
|
+
}
|
|
136
|
+
interface EventColumnsClear {
|
|
137
|
+
get $beanFullName(): 'a-orm.event.columnsClear';
|
|
138
|
+
get $onionName(): 'a-orm:columnsClear';
|
|
139
|
+
}
|
|
140
|
+
interface EventDatabaseClientReload {
|
|
141
|
+
}
|
|
142
|
+
interface EventDatabaseClientReload {
|
|
143
|
+
get $beanFullName(): 'a-orm.event.databaseClientReload';
|
|
144
|
+
get $onionName(): 'a-orm:databaseClientReload';
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** event: end */
|
|
148
|
+
/** event: begin */
|
|
149
|
+
import type { EventClientNameReal } from '../bean/event.clientNameReal.ts';
|
|
150
|
+
import type { EventColumnsClear } from '../bean/event.columnsClear.ts';
|
|
151
|
+
import type { EventDatabaseClientReload } from '../bean/event.databaseClientReload.ts';
|
|
152
|
+
export interface IModuleEvent {
|
|
153
|
+
'clientNameReal': EventClientNameReal;
|
|
154
|
+
'columnsClear': EventColumnsClear;
|
|
155
|
+
'databaseClientReload': EventDatabaseClientReload;
|
|
156
|
+
}
|
|
157
|
+
/** event: end */
|
|
158
|
+
/** event: begin */
|
|
159
|
+
import type { TypeEventClientNameRealData, TypeEventClientNameRealResult } from '../bean/event.clientNameReal.ts';
|
|
160
|
+
import type { TypeEventColumnsClearData, TypeEventColumnsClearResult } from '../bean/event.columnsClear.ts';
|
|
161
|
+
import type { TypeEventDatabaseClientReloadData, TypeEventDatabaseClientReloadResult } from '../bean/event.databaseClientReload.ts';
|
|
162
|
+
import type { EventOn } from 'vona-module-a-event';
|
|
163
|
+
declare module 'vona-module-a-event' {
|
|
164
|
+
interface IEventRecord {
|
|
165
|
+
'a-orm:clientNameReal': EventOn<TypeEventClientNameRealData, TypeEventClientNameRealResult>;
|
|
166
|
+
'a-orm:columnsClear': EventOn<TypeEventColumnsClearData, TypeEventColumnsClearResult>;
|
|
167
|
+
'a-orm:databaseClientReload': EventOn<TypeEventDatabaseClientReloadData, TypeEventDatabaseClientReloadResult>;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/** event: end */
|
|
171
|
+
/** schedule: begin */
|
|
172
|
+
export * from '../bean/schedule.softDeletionPrune.ts';
|
|
173
|
+
import { type IDecoratorScheduleOptions } from 'vona-module-a-schedule';
|
|
174
|
+
declare module 'vona-module-a-schedule' {
|
|
175
|
+
interface IScheduleRecord {
|
|
176
|
+
'a-orm:softDeletionPrune': IDecoratorScheduleOptions;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
declare module 'vona-module-a-orm' {
|
|
180
|
+
interface ScheduleSoftDeletionPrune {
|
|
181
|
+
}
|
|
182
|
+
interface ScheduleSoftDeletionPrune {
|
|
183
|
+
get $beanFullName(): 'a-orm.schedule.softDeletionPrune';
|
|
184
|
+
get $onionName(): 'a-orm:softDeletionPrune';
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/** schedule: end */
|
|
188
|
+
/** config: begin */
|
|
189
|
+
export * from '../config/config.ts';
|
|
190
|
+
import type { config } from '../config/config.ts';
|
|
191
|
+
export declare const locales: {
|
|
192
|
+
'en-us': {
|
|
193
|
+
TableIdentity: string;
|
|
194
|
+
CreatedAt: string;
|
|
195
|
+
UpdatedAt: string;
|
|
196
|
+
Deleted: string;
|
|
197
|
+
InstanceId: string;
|
|
198
|
+
ShouldSpecifyTable: string;
|
|
199
|
+
};
|
|
200
|
+
'zh-cn': {
|
|
201
|
+
TableIdentity: string;
|
|
202
|
+
CreatedAt: string;
|
|
203
|
+
UpdatedAt: string;
|
|
204
|
+
Deleted: string;
|
|
205
|
+
InstanceId: string;
|
|
206
|
+
ShouldSpecifyTable: string;
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
/** locale: end */
|
|
210
|
+
/** error: begin */
|
|
211
|
+
export * from '../config/errors.ts';
|
|
212
|
+
import type { Errors } from '../config/errors.ts';
|
|
213
|
+
/** error: end */
|
|
214
|
+
/** main: begin */
|
|
215
|
+
export * from '../main.ts';
|
|
216
|
+
/** main: end */
|
|
217
|
+
/** scope: begin */
|
|
218
|
+
import { BeanScopeBase, type BeanScopeUtil, type TypeModuleConfig, type TypeModuleErrors, type TypeModuleLocales, type TypeLocaleBase } from 'vona';
|
|
219
|
+
export declare class ScopeModuleAOrm extends BeanScopeBase {
|
|
220
|
+
}
|
|
221
|
+
export interface ScopeModuleAOrm {
|
|
222
|
+
util: BeanScopeUtil;
|
|
223
|
+
config: TypeModuleConfig<typeof config>;
|
|
224
|
+
error: TypeModuleErrors<typeof Errors>;
|
|
225
|
+
locale: TypeModuleLocales<(typeof locales)[TypeLocaleBase]>;
|
|
226
|
+
service: IModuleService;
|
|
227
|
+
broadcast: IModuleBroadcast;
|
|
228
|
+
event: IModuleEvent;
|
|
229
|
+
}
|
|
230
|
+
import 'vona';
|
|
231
|
+
declare module 'vona' {
|
|
232
|
+
interface IBeanScopeRecord {
|
|
233
|
+
'a-orm': ScopeModuleAOrm;
|
|
234
|
+
}
|
|
235
|
+
interface IBeanScopeContainer {
|
|
236
|
+
orm: ScopeModuleAOrm;
|
|
237
|
+
}
|
|
238
|
+
interface IBeanScopeConfig {
|
|
239
|
+
'a-orm': ReturnType<typeof config>;
|
|
240
|
+
}
|
|
241
|
+
interface IBeanScopeLocale {
|
|
242
|
+
'a-orm': (typeof locales)[TypeLocaleBase];
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
export declare function $locale<K extends keyof (typeof locales)[TypeLocaleBase]>(key: K): `a-orm::${K}`;
|
|
246
|
+
/** scope: end */
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Next, NextSync } from 'vona';
|
|
2
|
+
import type { IAopMethodExecute, IDecoratorAopMethodOptions } from 'vona-module-a-aspect';
|
|
3
|
+
import type { ITransactionOptions } from '../types/transaction.ts';
|
|
4
|
+
import { BeanAopMethodBase } from 'vona';
|
|
5
|
+
export interface IAopMethodOptionsTransaction extends IDecoratorAopMethodOptions, ITransactionOptions {
|
|
6
|
+
}
|
|
7
|
+
export declare class AopMethodTransaction extends BeanAopMethodBase implements IAopMethodExecute {
|
|
8
|
+
execute(options: IAopMethodOptionsTransaction, _args: [], next: Next | NextSync, _receiver: any, _prop: string): Promise<any> | any;
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FunctionAsync } from 'vona';
|
|
2
|
+
import type { ConfigDatabaseClient } from '../types/config.ts';
|
|
3
|
+
import type { IDatabaseClientRecord, IDbInfo } from '../types/database.ts';
|
|
4
|
+
import { BeanBase } from 'vona';
|
|
5
|
+
import { ServiceDatabaseClient } from '../service/databaseClient_.ts';
|
|
6
|
+
export declare class BeanDatabase extends BeanBase {
|
|
7
|
+
get current(): import("vona-module-a-orm").ServiceDb;
|
|
8
|
+
getClient(dbInfoOrClientName?: Partial<IDbInfo> | keyof IDatabaseClientRecord, clientConfig?: ConfigDatabaseClient): ServiceDatabaseClient;
|
|
9
|
+
getDb(dbInfoOrClientName?: Partial<IDbInfo> | keyof IDatabaseClientRecord, clientConfig?: ConfigDatabaseClient): import("vona-module-a-orm").ServiceDb;
|
|
10
|
+
switchDbIsolate<RESULT>(fn: FunctionAsync<RESULT>, dbInfoOrClientName?: Partial<IDbInfo> | keyof IDatabaseClientRecord): Promise<RESULT>;
|
|
11
|
+
switchDb<RESULT>(fn: FunctionAsync<RESULT>, dbInfoOrClientName?: Partial<IDbInfo> | keyof IDatabaseClientRecord): Promise<RESULT>;
|
|
12
|
+
}
|