onecore 0.5.1 → 0.5.3
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/lib/index.js +4 -0
- package/package.json +1 -1
- package/src/db.ts +9 -1
- package/src/index.ts +4 -3
package/lib/index.js
CHANGED
|
@@ -149,3 +149,7 @@ var SavedUseCase = (function (_super) {
|
|
|
149
149
|
return SavedUseCase;
|
|
150
150
|
}(SavedService));
|
|
151
151
|
exports.SavedUseCase = SavedUseCase;
|
|
152
|
+
function isSuccessful(res) {
|
|
153
|
+
return (typeof res === "number" && res <= 0) || Array.isArray(res) ? false : true;
|
|
154
|
+
}
|
|
155
|
+
exports.isSuccessful = isSuccessful;
|
package/package.json
CHANGED
package/src/db.ts
CHANGED
|
@@ -13,10 +13,18 @@ export interface SimpleDB {
|
|
|
13
13
|
interface StringMap {
|
|
14
14
|
[key: string]: string;
|
|
15
15
|
}
|
|
16
|
-
export interface
|
|
16
|
+
export interface Executor {
|
|
17
17
|
driver: string;
|
|
18
18
|
param(i: number): string;
|
|
19
19
|
exec(sql: string, args?: any[], ctx?: any): Promise<number>;
|
|
20
20
|
execBatch(statements: Statement[], firstSuccess?: boolean, ctx?: any): Promise<number>;
|
|
21
21
|
query<T>(sql: string, args?: any[], m?: StringMap, bools?: Attribute[], ctx?: any): Promise<T[]>;
|
|
22
22
|
}
|
|
23
|
+
export interface Transaction extends Executor {
|
|
24
|
+
commit(): Promise<void>
|
|
25
|
+
rollback(): Promise<void>
|
|
26
|
+
end(): Promise<void>
|
|
27
|
+
}
|
|
28
|
+
export interface DB extends Executor {
|
|
29
|
+
beginTransaction(): Promise<Transaction>
|
|
30
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -55,10 +55,8 @@ export type Log = (msg: string) => void;
|
|
|
55
55
|
export type LogFunc = Log;
|
|
56
56
|
|
|
57
57
|
import { Attributes } from './metadata';
|
|
58
|
-
import { Filter, SearchResult } from './model';
|
|
59
|
-
// import { GenericRepository } from './repository/GenericRepository';
|
|
58
|
+
import { ErrorMessage, Filter, SearchResult } from './model';
|
|
60
59
|
import { GenericSearchService } from './service/GenericSearchService';
|
|
61
|
-
// import { GenericSearchService } from './service/GenericSearchService';
|
|
62
60
|
import { GenericService } from './service/GenericService';
|
|
63
61
|
import { SearchRepository } from './repository/SearchRepository';
|
|
64
62
|
import { GenericSearchRepository } from './repository/GenericSearchRepository';
|
|
@@ -259,3 +257,6 @@ export class SavedService<UID, ID> {
|
|
|
259
257
|
// tslint:disable-next-line:max-classes-per-file
|
|
260
258
|
export class SavedUseCase<ID, T> extends SavedService<ID, T> {
|
|
261
259
|
}
|
|
260
|
+
export function isSuccessful<T>(res: number | T | ErrorMessage[]): boolean {
|
|
261
|
+
return (typeof res === "number" && res <= 0) || Array.isArray(res) ? false : true
|
|
262
|
+
}
|