query-core 0.1.18 → 0.1.19
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/services.js +6 -0
- package/package.json +1 -1
- package/src/batch.ts +3 -0
- package/src/index.ts +1 -0
- package/src/services.ts +12 -1
- package/tsconfig.json +1 -0
package/lib/services.js
CHANGED
|
@@ -14,6 +14,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
})();
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
var build_1 = require("./build");
|
|
17
|
+
function useGet(table, q, attrs, param, fromDB) {
|
|
18
|
+
var l = new SqlLoader(table, q, attrs, param, fromDB);
|
|
19
|
+
return l.load;
|
|
20
|
+
}
|
|
21
|
+
exports.useGet = useGet;
|
|
22
|
+
exports.useLoad = useGet;
|
|
17
23
|
var SqlLoader = (function () {
|
|
18
24
|
function SqlLoader(table, query, attrs, param, fromDB) {
|
|
19
25
|
this.table = table;
|
package/package.json
CHANGED
package/src/batch.ts
CHANGED
|
@@ -26,6 +26,7 @@ export class SqlInserter<T> {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
// tslint:disable-next-line:max-classes-per-file
|
|
29
30
|
export class SqlUpdater<T> {
|
|
30
31
|
version?: string;
|
|
31
32
|
constructor(public exec: (sql: string, args?: any[]) => Promise<number>, public table: string, public attributes: Attributes, public param: (i: number) => string, public map?: (v: T) => T) {
|
|
@@ -51,6 +52,7 @@ export class SqlUpdater<T> {
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
}
|
|
55
|
+
// tslint:disable-next-line:max-classes-per-file
|
|
54
56
|
export class SqlBatchInserter<T> {
|
|
55
57
|
version?: string;
|
|
56
58
|
constructor(public exec: (sql: string, args?: any[]) => Promise<number>, public table: string, public attributes: Attributes, public param: ((i: number) => string)|boolean, public map?: (v: T) => T) {
|
|
@@ -80,6 +82,7 @@ export class SqlBatchInserter<T> {
|
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
}
|
|
85
|
+
// tslint:disable-next-line:max-classes-per-file
|
|
83
86
|
export class SqlBatchUpdater<T> {
|
|
84
87
|
version?: string;
|
|
85
88
|
constructor(public execBatch: (statements: Statement[]) => Promise<number>, public table: string, public attributes: Attributes, public param: (i: number) => string, protected notSkipInvalid?: boolean, public map?: (v: T) => T) {
|
package/src/index.ts
CHANGED
|
@@ -54,6 +54,7 @@ export interface Config {
|
|
|
54
54
|
export class resource {
|
|
55
55
|
static string?: boolean;
|
|
56
56
|
}
|
|
57
|
+
// tslint:disable-next-line:max-classes-per-file
|
|
57
58
|
export class Loader<T> {
|
|
58
59
|
map?: StringMap;
|
|
59
60
|
constructor(public query: (sql: string, args?: any[], m?: StringMap, bools?: Attribute[]) => Promise<T[]>, public sql: string, m?: StringMap, public bools?: Attribute[]) {
|
package/src/services.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {attributes, buildToDelete, buildToInsert, buildToUpdate, exist, metadata, select,
|
|
1
|
+
import {attributes, buildToDelete, buildToInsert, buildToUpdate, exist, metadata, select, version} from './build';
|
|
2
2
|
import {Attribute, Attributes, Statement, StringMap} from './metadata';
|
|
3
3
|
import {SearchResult} from './search';
|
|
4
4
|
|
|
@@ -7,6 +7,17 @@ export interface Filter {
|
|
|
7
7
|
sort?: string;
|
|
8
8
|
q?: string;
|
|
9
9
|
}
|
|
10
|
+
export type Load<T, ID> = (id: ID, ctx?: any) => Promise<T|null>;
|
|
11
|
+
export type Get<T, ID> = Load<T, ID>;
|
|
12
|
+
export function useGet<T, ID>(table: string,
|
|
13
|
+
q: <K>(sql: string, args?: any[], m?: StringMap, bools?: Attribute[], ctx?: any) => Promise<K[]>,
|
|
14
|
+
attrs: Attributes|string[],
|
|
15
|
+
param: (i: number) => string,
|
|
16
|
+
fromDB?: (v: T) => T): Load<T, ID> {
|
|
17
|
+
const l = new SqlLoader<T, ID>(table, q, attrs, param, fromDB);
|
|
18
|
+
return l.load;
|
|
19
|
+
}
|
|
20
|
+
export const useLoad = useGet;
|
|
10
21
|
export class SqlLoader<T, ID> {
|
|
11
22
|
primaryKeys: Attribute[];
|
|
12
23
|
map?: StringMap;
|