query-core 0.1.29 → 0.1.31
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/build.js +29 -8
- package/lib/index.js +55 -60
- package/lib/search.js +107 -107
- package/lib/services.js +392 -238
- package/package.json +1 -1
- package/src/build.ts +25 -8
- package/src/index.ts +2 -4
- package/src/services.ts +4 -4
package/package.json
CHANGED
package/src/build.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import {Attribute, Attributes, Statement, StringMap} from './metadata';
|
|
2
2
|
|
|
3
|
+
// tslint:disable-next-line:class-name
|
|
4
|
+
export class resource {
|
|
5
|
+
static string?: boolean;
|
|
6
|
+
static ignoreDatetime?: boolean;
|
|
7
|
+
}
|
|
3
8
|
export function params(length: number, p: (i: number) => string, from?: number): string[] {
|
|
4
9
|
if (from === undefined || from == null) {
|
|
5
10
|
from = 0;
|
|
@@ -155,9 +160,13 @@ export function buildToInsert<T>(obj: T, table: string, attrs: Attributes, build
|
|
|
155
160
|
}
|
|
156
161
|
}
|
|
157
162
|
} else {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
163
|
+
if (resource.ignoreDatetime && typeof v === 'string' && attr.type === 'datetime') {
|
|
164
|
+
values.push(`'${v}'`);
|
|
165
|
+
} else {
|
|
166
|
+
const p = buildParam(i++);
|
|
167
|
+
values.push(p);
|
|
168
|
+
args.push(v);
|
|
169
|
+
}
|
|
161
170
|
}
|
|
162
171
|
}
|
|
163
172
|
}
|
|
@@ -240,9 +249,13 @@ export function buildToInsertBatch<T>(objs: T[], table: string, attrs: Attribute
|
|
|
240
249
|
}
|
|
241
250
|
}
|
|
242
251
|
} else {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
252
|
+
if (resource.ignoreDatetime && typeof v === 'string' && attr.type === 'datetime') {
|
|
253
|
+
values.push(`'${v}'`);
|
|
254
|
+
} else {
|
|
255
|
+
const p = buildParam(i++);
|
|
256
|
+
values.push(p);
|
|
257
|
+
args.push(v);
|
|
258
|
+
}
|
|
246
259
|
}
|
|
247
260
|
}
|
|
248
261
|
}
|
|
@@ -380,8 +393,12 @@ export function buildToUpdate<T>(obj: T, table: string, attrs: Attributes, build
|
|
|
380
393
|
}
|
|
381
394
|
}
|
|
382
395
|
} else {
|
|
383
|
-
|
|
384
|
-
|
|
396
|
+
if (resource.ignoreDatetime && typeof v === 'string' && attr.type === 'datetime') {
|
|
397
|
+
x = `'${v}'`;
|
|
398
|
+
} else {
|
|
399
|
+
x = buildParam(i++);
|
|
400
|
+
args.push(v);
|
|
401
|
+
}
|
|
385
402
|
}
|
|
386
403
|
colSet.push(`${field}=${x}`);
|
|
387
404
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {Checker} from './health';
|
|
2
2
|
export {Checker as SqlChecker};
|
|
3
3
|
|
|
4
|
+
import {resource} from './build';
|
|
4
5
|
import {Attribute, StringMap} from './metadata';
|
|
5
6
|
import {SqlLoader, SqlSearchLoader, SqlSearchWriter, SqlWriter} from './services';
|
|
6
7
|
// export {SqlLoader as SqlLoadRepository};
|
|
@@ -50,10 +51,7 @@ export interface Config {
|
|
|
50
51
|
min?: number | undefined;
|
|
51
52
|
idleTimeoutMillis?: number | undefined;
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
-
export class resource {
|
|
55
|
-
static string?: boolean;
|
|
56
|
-
}
|
|
54
|
+
|
|
57
55
|
// tslint:disable-next-line:max-classes-per-file
|
|
58
56
|
export class Loader<T> {
|
|
59
57
|
map?: StringMap;
|
package/src/services.ts
CHANGED
|
@@ -207,12 +207,12 @@ export class GenericRepository<T, K1, K2> extends SqlLoadRepository<T, K1, K2> {
|
|
|
207
207
|
if (x) {
|
|
208
208
|
this.version = x.name;
|
|
209
209
|
}
|
|
210
|
-
this.
|
|
210
|
+
this.create = this.create.bind(this);
|
|
211
211
|
this.update = this.update.bind(this);
|
|
212
212
|
this.patch = this.patch.bind(this);
|
|
213
213
|
this.delete = this.delete.bind(this);
|
|
214
214
|
}
|
|
215
|
-
|
|
215
|
+
create(obj: T, ctx?: any): Promise<number> {
|
|
216
216
|
let obj2 = obj;
|
|
217
217
|
if (this.toDB) {
|
|
218
218
|
obj2 = this.toDB(obj);
|
|
@@ -588,12 +588,12 @@ export class SqlWriter<T, ID> extends SqlLoader<T, ID> {
|
|
|
588
588
|
if (x) {
|
|
589
589
|
this.version = x.name;
|
|
590
590
|
}
|
|
591
|
-
this.
|
|
591
|
+
this.create = this.create.bind(this);
|
|
592
592
|
this.update = this.update.bind(this);
|
|
593
593
|
this.patch = this.patch.bind(this);
|
|
594
594
|
this.delete = this.delete.bind(this);
|
|
595
595
|
}
|
|
596
|
-
|
|
596
|
+
create(obj: T, ctx?: any): Promise<number> {
|
|
597
597
|
let obj2 = obj;
|
|
598
598
|
if (this.toDB) {
|
|
599
599
|
obj2 = this.toDB(obj);
|