@nattyjs/orm 0.0.1-beta.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/README.md +11 -0
- package/dist/index.cjs +654 -0
- package/dist/index.d.ts +122 -0
- package/dist/index.mjs +636 -0
- package/package.json +26 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { ClassType, List } from '@nattyjs/common';
|
|
2
|
+
|
|
3
|
+
interface IDbContext {
|
|
4
|
+
connection: IDbConnection;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface IDbConnection {
|
|
8
|
+
useTransaction(connection: any): any;
|
|
9
|
+
releaseTransaction(): void;
|
|
10
|
+
beginTransaction(isolationLevel?: any, dbContexts?: IDbContext[]): any;
|
|
11
|
+
commitTransaction(): void;
|
|
12
|
+
rollbackTransaction(): void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare enum EntityState {
|
|
16
|
+
added = 0,
|
|
17
|
+
updated = 1,
|
|
18
|
+
deleted = 2
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface DbEntityInfo {
|
|
22
|
+
tableName?: string;
|
|
23
|
+
entity?: {
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
};
|
|
26
|
+
primaryKeys?: Array<string>;
|
|
27
|
+
foreignKey?: string;
|
|
28
|
+
propsDbConfig?: Map<string, DbEntityInfo>;
|
|
29
|
+
properties?: {
|
|
30
|
+
[key: string]: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
interface DbDeleteEntityInfo extends DbEntityInfo {
|
|
34
|
+
whereClause: any;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare class ChangeTracker {
|
|
38
|
+
private entries;
|
|
39
|
+
get addedEntries(): Array<DbEntityInfo>;
|
|
40
|
+
get updatedEntries(): DbEntityInfo[];
|
|
41
|
+
get deletedEntries(): DbEntityInfo[];
|
|
42
|
+
clear(): void;
|
|
43
|
+
addItem(entity: DbEntityInfo | DbDeleteEntityInfo, entityState: EntityState): void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare class DbConnectionContext {
|
|
47
|
+
connection: any;
|
|
48
|
+
useSqlServer(options: any): void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare abstract class DbContext implements IDbContext {
|
|
52
|
+
private dbConnectionInfo;
|
|
53
|
+
get connection(): IDbConnection;
|
|
54
|
+
private get internalConnection();
|
|
55
|
+
private get queryConnection();
|
|
56
|
+
changeTracker: ChangeTracker;
|
|
57
|
+
constructor();
|
|
58
|
+
protected onDbSetRegistering(dbSets?: {
|
|
59
|
+
[key: string]: () => ClassType<any>;
|
|
60
|
+
}): void;
|
|
61
|
+
protected onSpRegistering(sps?: {
|
|
62
|
+
[key: string]: {
|
|
63
|
+
model: () => ClassType<any>;
|
|
64
|
+
spName: string;
|
|
65
|
+
};
|
|
66
|
+
}): void;
|
|
67
|
+
protected abstract onConfiguring(connectionContext: DbConnectionContext): void;
|
|
68
|
+
saveChanges(): Promise<unknown>;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
type FilterExpression<T> = (t: T) => boolean;
|
|
72
|
+
|
|
73
|
+
declare enum QueryAction {
|
|
74
|
+
select = 0,
|
|
75
|
+
add = 1,
|
|
76
|
+
update = 2,
|
|
77
|
+
delete = 3
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface ExecuteQueryConfig extends DbEntityInfo {
|
|
81
|
+
columns?: string[];
|
|
82
|
+
whereClause?: any;
|
|
83
|
+
queryAction?: QueryAction;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
interface DataQueryConnection extends IDbConnection {
|
|
87
|
+
executeQuery(query: ExecuteQueryConfig): Promise<any[]>;
|
|
88
|
+
executeSp(spName: string, params: {
|
|
89
|
+
[key: string]: any;
|
|
90
|
+
}): any;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare class DbSet<T> {
|
|
94
|
+
private type;
|
|
95
|
+
private queryConnection;
|
|
96
|
+
private changeTracker;
|
|
97
|
+
private columns;
|
|
98
|
+
private whereClause;
|
|
99
|
+
constructor(type: ClassType<T>, queryConnection: DataQueryConnection, changeTracker: ChangeTracker);
|
|
100
|
+
filter(expression: FilterExpression<T>): this;
|
|
101
|
+
firstOrDefault(expression?: FilterExpression<T>): Promise<T | null>;
|
|
102
|
+
add(entity: Partial<T>): Promise<void>;
|
|
103
|
+
update(entity: Partial<T>): Promise<void>;
|
|
104
|
+
delete(expression: FilterExpression<T>): Promise<void>;
|
|
105
|
+
toList(): Promise<List<T>>;
|
|
106
|
+
private execute;
|
|
107
|
+
private getTableName;
|
|
108
|
+
private getProperties;
|
|
109
|
+
private getPropsDbConfig;
|
|
110
|
+
private getPrimaryKeys;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
declare class StoreProc<SpName, Entity, SpParamterModel> {
|
|
114
|
+
private spName;
|
|
115
|
+
private type;
|
|
116
|
+
private queryConnection;
|
|
117
|
+
constructor(spName: string, type: ClassType<Entity>, queryConnection: DataQueryConnection);
|
|
118
|
+
execute(params: SpParamterModel): Promise<List<Entity>>;
|
|
119
|
+
private get properties();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export { DbContext, DbSet, StoreProc };
|