db-wrapper 0.0.5 → 0.0.8

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.
@@ -1,375 +1,209 @@
1
+ import { __decorate, __awaiter } from 'tslib';
1
2
  import { Injectable, InjectionToken, NgModule } from '@angular/core';
2
3
 
3
- /**
4
- * @fileoverview added by tsickle
5
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6
- */
7
- class WindowService {
8
- /**
9
- * @return {?}
10
- */
4
+ let WindowService = class WindowService {
11
5
  get nativeWindow() {
12
6
  return _window();
13
7
  }
14
- }
15
- WindowService.decorators = [
16
- { type: Injectable }
17
- ];
18
- /**
19
- * @return {?}
20
- */
8
+ };
9
+ WindowService = __decorate([
10
+ Injectable()
11
+ ], WindowService);
21
12
  function _window() {
22
13
  // Return the global native browser window object
23
14
  return typeof window !== 'undefined' ? window : undefined;
24
15
  }
25
16
 
26
- /**
27
- * @fileoverview added by tsickle
28
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
29
- */
30
17
  class DbWrapperService {
31
- /**
32
- * @param {?} dbConfig
33
- * @param {?=} dbSchema
34
- */
35
18
  constructor(dbConfig, dbSchema) {
36
19
  this._dbName = dbConfig.dbName;
37
20
  this._location = dbConfig.location || 'default';
38
21
  this._iosDatabaseLocation = dbConfig.iosDatabaseLocation || 'Library';
39
- /** @type {?} */
40
22
  const window = (new WindowService()).nativeWindow;
41
23
  if (dbSchema) {
42
24
  this.schema = dbSchema;
43
25
  }
44
- this._readyPromise = new Promise((/**
45
- * @param {?} resolve
46
- * @param {?} reject
47
- * @return {?}
48
- */
49
- (resolve, reject) => {
26
+ this._readyPromise = new Promise((resolve, reject) => {
50
27
  if (typeof window.cordova === 'undefined') {
51
- setTimeout((/**
52
- * @return {?}
53
- */
54
- () => {
55
- this.init(dbSchema).then((/**
56
- * @return {?}
57
- */
58
- () => resolve())).catch((/**
59
- * @param {?} err
60
- * @return {?}
61
- */
62
- (err) => reject(err)));
63
- }), 500);
28
+ setTimeout(() => {
29
+ this.init(dbSchema).then(() => {
30
+ resolve();
31
+ })
32
+ .catch((err) => {
33
+ reject(err);
34
+ });
35
+ }, 500);
64
36
  }
65
37
  else {
66
- document.addEventListener('deviceready', (/**
67
- * @return {?}
68
- */
69
- () => {
38
+ document.addEventListener('deviceready', () => {
70
39
  console.log('dbWrapper: device ready.');
71
- this.initDevice(dbSchema).then((/**
72
- * @return {?}
73
- */
74
- () => resolve())).catch((/**
75
- * @param {?} err
76
- * @return {?}
77
- */
78
- (err) => reject(err)));
79
- }));
40
+ this.initDevice(dbSchema).then(() => resolve()).catch((err) => reject(err));
41
+ });
80
42
  }
81
- }));
43
+ });
82
44
  }
83
- /**
84
- * @return {?}
85
- */
86
45
  ready() {
87
46
  return this._readyPromise;
88
47
  }
89
- /**
90
- * @param {?} dbSchema
91
- * @return {?}
92
- */
93
48
  initDevice(dbSchema) {
94
- /** @type {?} */
95
49
  const window = (new WindowService()).nativeWindow;
96
- return new Promise((/**
97
- * @param {?} resolve
98
- * @param {?} reject
99
- * @return {?}
100
- */
101
- (resolve, reject) => {
50
+ return new Promise((resolve, reject) => {
102
51
  this.db = window.sqlitePlugin.openDatabase({
103
52
  name: this._dbName,
104
53
  location: this._location,
105
54
  androidLockWorkaround: 1
106
55
  });
107
56
  if (dbSchema) {
108
- this.generate(dbSchema).catch((/**
109
- * @param {?} err
110
- * @return {?}
111
- */
112
- err => {
57
+ this.generate(dbSchema).catch(err => {
113
58
  reject(err);
114
- })).then((/**
115
- * @return {?}
116
- */
117
- () => { resolve(); }));
59
+ }).then(() => { resolve(); });
118
60
  }
119
61
  else {
120
62
  resolve();
121
63
  }
122
- }));
64
+ });
123
65
  }
124
- /**
125
- * @param {?} dbSchema
126
- * @return {?}
127
- */
128
66
  init(dbSchema) {
129
- /** @type {?} */
130
67
  const window = (new WindowService()).nativeWindow;
131
- return new Promise((/**
132
- * @param {?} resolve
133
- * @param {?} reject
134
- * @return {?}
135
- */
136
- (resolve, reject) => {
68
+ return new Promise((resolve, reject) => {
137
69
  this.db = window.openDatabase(this._dbName, '1.0', 'database', -1);
138
70
  if (dbSchema) {
139
- this.generate(dbSchema).catch((/**
140
- * @param {?} err
141
- * @return {?}
142
- */
143
- err => {
71
+ this.generate(dbSchema).catch(err => {
144
72
  reject(err);
145
- })).then((/**
146
- * @return {?}
147
- */
148
- () => { resolve(); }));
73
+ }).then(() => {
74
+ resolve();
75
+ });
149
76
  }
150
77
  else {
151
78
  resolve();
152
79
  }
153
- }));
80
+ });
154
81
  }
155
- /**
156
- * @param {?} schema
157
- * @return {?}
158
- */
159
82
  generate(schema) {
160
- /** @type {?} */
161
83
  const sentences = [];
162
84
  this.schema = schema;
163
85
  if (schema.tables) {
164
- schema.tables.forEach((/**
165
- * @param {?} table
166
- * @return {?}
167
- */
168
- table => {
86
+ schema.tables.forEach(table => {
169
87
  sentences.push(this.createTable(table));
170
- }));
88
+ });
171
89
  }
172
90
  if (schema.views) {
173
- schema.views.forEach((/**
174
- * @param {?} view
175
- * @return {?}
176
- */
177
- view => {
91
+ schema.views.forEach(view => {
178
92
  sentences.push(this.createView(view));
179
- }));
93
+ });
180
94
  }
181
95
  if (sentences.length === 0) {
182
96
  throw new Error('Esquema de la base de datos vacia.');
183
97
  }
184
98
  return Promise.all(sentences);
185
99
  }
186
- /**
187
- * @param {?} table
188
- * @return {?}
189
- */
190
100
  createTable(table) {
191
- /** @type {?} */
192
- let sql = '';
193
- /** @type {?} */
194
- let sentences = [];
195
- /** @type {?} */
196
- let onConflictPrimary;
197
- table.columns.forEach((/**
198
- * @param {?} col
199
- * @return {?}
200
- */
201
- col => {
202
- sentences.push(this.defColumn(col));
203
- }));
204
- onConflictPrimary = 'on conflict fail';
205
- if (Array.isArray(table.primary)) {
206
- sentences.push(' CONSTRAINT identificador PRIMARY KEY (' + table.primary.join(',') + ') ' + onConflictPrimary);
207
- }
208
- if (typeof table.primary === 'string') {
209
- sentences.push(' CONSTRAINT identificador PRIMARY KEY (' + table.primary + ') ' + onConflictPrimary);
210
- }
211
- if (table.uniques) {
212
- table.uniques.forEach((/**
213
- * @param {?} uniq
214
- * @return {?}
215
- */
216
- uniq => {
217
- sentences.push(this.defUnique(uniq));
218
- }));
219
- }
220
- if (table.foreigns) {
221
- table.foreigns.forEach((/**
222
- * @param {?} fore
223
- * @return {?}
224
- */
225
- fore => {
226
- sentences.push(this.defForeign(fore));
227
- }));
228
- }
229
- sql = 'CREATE TABLE IF NOT EXISTS ' + table.name + ' (' + sentences.join(',') + ')';
230
- return this.query(sql);
101
+ return __awaiter(this, void 0, void 0, function* () {
102
+ let sql = '', onConflictPrimary;
103
+ const sentences = [], newColumns = [];
104
+ const tableDDL = yield this._tableExists(table.name);
105
+ if (tableDDL) {
106
+ table.columns.forEach(col => {
107
+ if (!this._columnExists(tableDDL, col.name)) {
108
+ newColumns.push(this.addColumn(table.name, col));
109
+ }
110
+ });
111
+ }
112
+ else {
113
+ table.columns.forEach(col => {
114
+ sentences.push(this.defColumn(col));
115
+ });
116
+ }
117
+ onConflictPrimary = 'on conflict fail';
118
+ if (Array.isArray(table.primary)) {
119
+ sentences.push(' CONSTRAINT identificador PRIMARY KEY (' + table.primary.join(',') + ') ' + onConflictPrimary);
120
+ }
121
+ if (typeof table.primary === 'string') {
122
+ sentences.push(' CONSTRAINT identificador PRIMARY KEY (' + table.primary + ') ' + onConflictPrimary);
123
+ }
124
+ if (table.uniques) {
125
+ table.uniques.forEach(uniq => {
126
+ sentences.push(this.defUnique(uniq));
127
+ });
128
+ }
129
+ if (table.foreigns) {
130
+ table.foreigns.forEach(fore => {
131
+ sentences.push(this.defForeign(fore));
132
+ });
133
+ }
134
+ if (tableDDL && newColumns.length !== 0) {
135
+ return Promise.all(newColumns)
136
+ .then(() => { console.log(`Table ${table.name} altered.`); })
137
+ .catch((err) => {
138
+ console.error(`Table ${table.name}: ${err.message}`);
139
+ throw new Error(`Table ${table.name}: ${err.message}`);
140
+ });
141
+ }
142
+ else if (!tableDDL) {
143
+ sql = 'CREATE TABLE IF NOT EXISTS ' + table.name + ' (' + sentences.join(',') + ')';
144
+ return this.query(sql)
145
+ .then(() => { console.log(`Table ${table.name} created.`); })
146
+ .catch((err) => {
147
+ console.error(`Table ${table.name}: ${err.message}`);
148
+ throw new Error(`Table ${table.name}: ${err.message}`);
149
+ });
150
+ }
151
+ else {
152
+ return Promise.resolve().then(() => { console.log(`Table ${table.name} initialized.`); });
153
+ }
154
+ });
231
155
  }
232
- /**
233
- * @param {?} view
234
- * @return {?}
235
- */
236
156
  createView(view) {
237
- /** @type {?} */
238
157
  let sql;
239
158
  sql = 'CREATE VIEW IF NOT EXISTS ' + view.name
240
159
  + ' AS ' + view.sql;
241
160
  return this.query(sql);
242
161
  }
243
- /**
244
- * @param {?} tableName
245
- * @return {?}
246
- */
247
162
  getSchemaTable(tableName) {
248
- /** @type {?} */
249
163
  let res;
250
- this.schema.tables.forEach((/**
251
- * @param {?} table
252
- * @return {?}
253
- */
254
- table => {
164
+ this.schema.tables.forEach(table => {
255
165
  if (table.name === tableName) {
256
166
  res = table;
257
167
  }
258
- }));
168
+ });
259
169
  return res;
260
170
  }
261
- /**
262
- * @param {?} table
263
- * @return {?}
264
- */
265
171
  getUniquesTable(table) {
266
- /** @type {?} */
267
172
  let res;
268
- table.uniques.forEach((/**
269
- * @param {?} uniq
270
- * @return {?}
271
- */
272
- uniq => {
173
+ table.uniques.forEach(uniq => {
273
174
  res[uniq.name] = uniq;
274
- }));
175
+ });
275
176
  return res;
276
177
  }
277
- /**
278
- * @param {?} query
279
- * @param {?=} bindings
280
- * @return {?}
281
- */
282
178
  query(query, bindings = []) {
283
- return new Promise((/**
284
- * @param {?} resolve
285
- * @param {?} reject
286
- * @return {?}
287
- */
288
- (resolve, reject) => {
179
+ return new Promise((resolve, reject) => {
289
180
  if (query.indexOf('select') === 0) {
290
- this.db.readTransaction((/**
291
- * @param {?} transaction
292
- * @return {?}
293
- */
294
- (transaction) => {
295
- transaction.executeSql(query, bindings, (/**
296
- * @param {?} transaction
297
- * @param {?} result
298
- * @return {?}
299
- */
300
- (transaction, result) => {
181
+ this.db.readTransaction((transaction) => {
182
+ transaction.executeSql(query, bindings, (transaction, result) => {
301
183
  resolve(result);
302
- }), (/**
303
- * @param {?} transaction
304
- * @param {?} error
305
- * @return {?}
306
- */
307
- (transaction, error) => {
184
+ }, (transaction, error) => {
308
185
  reject(error);
309
- }));
310
- }), (/**
311
- * @param {?} err
312
- * @return {?}
313
- */
314
- (err) => reject(err)));
186
+ });
187
+ }, (err) => reject(err));
315
188
  }
316
189
  else {
317
- this.db.transaction((/**
318
- * @param {?} transaction
319
- * @return {?}
320
- */
321
- (transaction) => {
322
- transaction.executeSql(query, bindings, (/**
323
- * @param {?} transaction
324
- * @param {?} result
325
- * @return {?}
326
- */
327
- (transaction, result) => {
190
+ this.db.transaction((transaction) => {
191
+ transaction.executeSql(query, bindings, (transaction, result) => {
328
192
  resolve(result);
329
- }), (/**
330
- * @param {?} transaction
331
- * @param {?} error
332
- * @return {?}
333
- */
334
- (transaction, error) => {
193
+ }, (transaction, error) => {
335
194
  reject(error);
336
- }));
337
- }), (/**
338
- * @param {?} err
339
- * @return {?}
340
- */
341
- (err) => reject(err)));
195
+ });
196
+ }, (err) => reject(err));
342
197
  }
343
- }));
198
+ });
344
199
  }
345
- /**
346
- * @param {?} query
347
- * @param {?=} bindings
348
- * @return {?}
349
- */
350
200
  Count(query, bindings = []) {
351
- return this.query(query, bindings).then((/**
352
- * @param {?} rows
353
- * @return {?}
354
- */
355
- rows => {
201
+ return this.query(query, bindings).then(rows => {
356
202
  return this.rowsCount(rows);
357
- }));
203
+ });
358
204
  }
359
- /**
360
- * @param {?} table
361
- * @param {?} bindings
362
- * @return {?}
363
- */
364
205
  insert(table, bindings) {
365
- /** @type {?} */
366
- let sql = '';
367
- /** @type {?} */
368
- let sqlBinds = [];
369
- /** @type {?} */
370
- let sqlKeys = [];
371
- /** @type {?} */
372
- let sqlValues = [];
206
+ let sql = '', sqlBinds = [], sqlKeys = [], sqlValues = [];
373
207
  sql = sql + 'insert into ' + table + ' ';
374
208
  for (const index in bindings) {
375
209
  if (bindings.hasOwnProperty(index)) {
@@ -379,54 +213,21 @@ class DbWrapperService {
379
213
  }
380
214
  }
381
215
  sql = sql + '(' + sqlKeys.join(',') + ') values (' + sqlBinds.join(',') + ')';
382
- return new Promise((/**
383
- * @param {?} resolve
384
- * @param {?} reject
385
- * @return {?}
386
- */
387
- (resolve, reject) => {
388
- this.db.transaction((/**
389
- * @param {?} transaction
390
- * @return {?}
391
- */
392
- transaction => {
393
- transaction.executeSql(sql, sqlValues, (/**
394
- * @param {?} transaction
395
- * @param {?} result
396
- * @return {?}
397
- */
398
- (transaction, result) => {
216
+ return new Promise((resolve, reject) => {
217
+ this.db.transaction(transaction => {
218
+ transaction.executeSql(sql, sqlValues, (transaction, result) => {
399
219
  resolve(result);
400
- }), (/**
401
- * @param {?} transaction
402
- * @param {?} error
403
- * @return {?}
404
- */
405
- (transaction, error) => {
220
+ }, (transaction, error) => {
406
221
  reject(error);
407
- }));
408
- }));
409
- }));
222
+ });
223
+ });
224
+ });
410
225
  }
411
- /**
412
- * @param {?} table
413
- * @param {?} bindings
414
- * @param {?} where
415
- * @return {?}
416
- */
417
226
  update(table, bindings, where) {
418
- /** @type {?} */
419
- let sql = '';
420
- /** @type {?} */
421
- let sqlBinds = [];
422
- /** @type {?} */
423
- let sqlKeys = [];
424
- /** @type {?} */
425
- let sqlValues = [];
227
+ let sql = '', sqlBinds = [], sqlKeys = [], sqlValues = [];
426
228
  sql = sql + 'update ' + table + ' set ';
427
229
  for (let index in bindings) {
428
230
  if (bindings.hasOwnProperty(index)) {
429
- /** @type {?} */
430
231
  let newObj = bindings[index];
431
232
  if (typeof newObj === 'object' && newObj !== null) {
432
233
  sqlValues.push(newObj.value);
@@ -459,105 +260,52 @@ class DbWrapperService {
459
260
  }
460
261
  }
461
262
  sql = sql + sqlBinds.join(',') + ' where ' + sqlKeys.join(' and ');
462
- return new Promise((/**
463
- * @param {?} resolve
464
- * @param {?} reject
465
- * @return {?}
466
- */
467
- (resolve, reject) => {
468
- this.db.transaction((/**
469
- * @param {?} transaction
470
- * @return {?}
471
- */
472
- transaction => {
473
- transaction.executeSql(sql, sqlValues, (/**
474
- * @param {?} transaction
475
- * @param {?} result
476
- * @return {?}
477
- */
478
- (transaction, result) => {
263
+ return new Promise((resolve, reject) => {
264
+ this.db.transaction(transaction => {
265
+ transaction.executeSql(sql, sqlValues, (transaction, result) => {
479
266
  resolve(result);
480
- }), (/**
481
- * @param {?} transaction
482
- * @param {?} error
483
- * @return {?}
484
- */
485
- (transaction, error) => {
267
+ }, (transaction, error) => {
486
268
  reject(error);
487
- }));
488
- }));
489
- }));
269
+ });
270
+ });
271
+ });
490
272
  }
491
- /**
492
- * @param {?} tables
493
- * @return {?}
494
- */
495
273
  dropTable(tables) {
496
- /** @type {?} */
497
274
  let cont = 1;
498
275
  cont = tables.length;
499
- return new Promise((/**
500
- * @param {?} resolve
501
- * @param {?} reject
502
- * @return {?}
503
- */
504
- (resolve, reject) => {
505
- tables.some((/**
506
- * @param {?} table
507
- * @return {?}
508
- */
509
- table => {
276
+ return new Promise((resolve, reject) => {
277
+ tables.some(table => {
510
278
  if (cont !== 0) {
511
279
  this.query('DROP TABLE ' + table)
512
- .then((/**
513
- * @return {?}
514
- */
515
- () => {
280
+ .then(() => {
516
281
  if (cont === 1) {
517
282
  resolve();
518
283
  }
519
284
  else {
520
285
  cont--;
521
286
  }
522
- }), (/**
523
- * @param {?} err
524
- * @return {?}
525
- */
526
- err => {
287
+ }, err => {
527
288
  cont = 0;
528
289
  reject(err);
529
290
  return true;
530
- }));
291
+ });
531
292
  return false;
532
293
  }
533
- }));
534
- }));
294
+ });
295
+ });
535
296
  }
536
- /**
537
- * @param {?} result
538
- * @return {?}
539
- */
540
297
  fetchAll(result) {
541
- /** @type {?} */
542
298
  let output = [];
543
299
  for (let i = 0; i < result.rows.length; i++) {
544
300
  output.push(result.rows.item(i));
545
301
  }
546
302
  return output;
547
303
  }
548
- /**
549
- * @param {?} result
550
- * @return {?}
551
- */
552
304
  fetch(result) {
553
- /** @type {?} */
554
- let objeto = undefined;
555
- /** @type {?} */
556
- let newObj = undefined;
305
+ let objeto = undefined, newObj = undefined;
557
306
  if (result.rows.length !== 0) {
558
307
  objeto = result.rows.item(0);
559
308
  newObj = {};
560
- /** @type {?} */
561
309
  const keys = Object.keys(objeto);
562
310
  for (let key in keys) {
563
311
  newObj[keys[key]] = objeto[keys[key]];
@@ -565,21 +313,27 @@ class DbWrapperService {
565
313
  }
566
314
  return newObj;
567
315
  }
568
- /**
569
- * @param {?} result
570
- * @return {?}
571
- */
572
316
  rowsCount(result) {
573
317
  return result.rows.length;
574
318
  }
319
+ tableExists(table) {
320
+ return this.query('select sql from sqlite_master ' +
321
+ 'where type=\'table\' and name=\'' + table + '\'')
322
+ .then(result => (this.rowsCount(result) === 1));
323
+ }
324
+ columnExists(table, column) {
325
+ return this._tableExists(table)
326
+ .then((tableDDL) => {
327
+ if (tableDDL) {
328
+ return this._columnExists(tableDDL, column);
329
+ }
330
+ else {
331
+ return false;
332
+ }
333
+ });
334
+ }
575
335
  /* Private */
576
- /**
577
- * @private
578
- * @param {?} col
579
- * @return {?}
580
- */
581
336
  defColumn(col) {
582
- /** @type {?} */
583
337
  let colSql;
584
338
  colSql = col.name + ' ' + col.type;
585
339
  if (!col.isNullable) {
@@ -597,16 +351,9 @@ class DbWrapperService {
597
351
  }
598
352
  return colSql;
599
353
  }
600
- /**
601
- * @private
602
- * @param {?} unique
603
- * @return {?}
604
- */
605
354
  defUnique(unique) {
606
- /** @type {?} */
607
355
  let uniqSql;
608
356
  // depende del entorno, producción o desarrollo
609
- /** @type {?} */
610
357
  const onConflictUnique = 'on conflict replace';
611
358
  if (Array.isArray(unique.fields)) {
612
359
  uniqSql = ` CONSTRAINT ${unique.name} UNIQUE ( ${unique.fields.join(',')} ) ${onConflictUnique} `;
@@ -616,13 +363,7 @@ class DbWrapperService {
616
363
  }
617
364
  return uniqSql;
618
365
  }
619
- /**
620
- * @private
621
- * @param {?} fore
622
- * @return {?}
623
- */
624
366
  defForeign(fore) {
625
- /** @type {?} */
626
367
  let foreSql;
627
368
  if (Array.isArray(fore.foreignKey)) {
628
369
  foreSql = ` FOREIGN KEY ( ${fore.foreignKey.join(',')} ) `;
@@ -638,14 +379,34 @@ class DbWrapperService {
638
379
  }
639
380
  return foreSql;
640
381
  }
382
+ _tableExists(table) {
383
+ return this.query('select sql from sqlite_master ' +
384
+ 'where type=\'table\' and name=\'' + table + '\'')
385
+ .then(result => {
386
+ if (this.rowsCount(result) === 1) {
387
+ return this.fetch(result).sql;
388
+ }
389
+ else {
390
+ return false;
391
+ }
392
+ });
393
+ }
394
+ _columnExists(tableDDL, column) {
395
+ if (tableDDL.indexOf(column) === -1) {
396
+ return false;
397
+ }
398
+ else {
399
+ return true;
400
+ }
401
+ }
402
+ addColumn(table, col) {
403
+ const colSql = this.defColumn(col);
404
+ const query = 'alter TABLE ' + table + ' add COLUMN ' + colSql;
405
+ return this.query(query);
406
+ }
641
407
  }
642
- /** @type {?} */
643
408
  const DB_CONFIG = new InjectionToken('dbWrapperConfig');
644
- /** @type {?} */
645
409
  const DB_SCHEMA = new InjectionToken('dbWrapperSchema');
646
- /**
647
- * @return {?}
648
- */
649
410
  function getDefaultDbConfig() {
650
411
  return {
651
412
  dbName: 'db.sqlite',
@@ -653,30 +414,16 @@ function getDefaultDbConfig() {
653
414
  iosDatabaseLocation: 'Library'
654
415
  };
655
416
  }
656
- /**
657
- * @param {?} dbConfig
658
- * @param {?=} dbSchema
659
- * @return {?}
660
- */
661
417
  function provideDbWrapper(dbConfig, dbSchema) {
662
- /** @type {?} */
663
418
  const config = !!dbConfig ? dbConfig : getDefaultDbConfig();
664
419
  return new DbWrapperService(config, dbSchema);
665
420
  }
666
421
 
667
- /**
668
- * @fileoverview added by tsickle
669
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
670
- */
671
- class DbWrapperModule {
672
- /**
673
- * @param {?} dbConfig
674
- * @param {?=} schema
675
- * @return {?}
676
- */
422
+ var DbWrapperModule_1;
423
+ let DbWrapperModule = DbWrapperModule_1 = class DbWrapperModule {
677
424
  static forRoot(dbConfig, schema) {
678
425
  return {
679
- ngModule: DbWrapperModule,
426
+ ngModule: DbWrapperModule_1,
680
427
  providers: [
681
428
  { provide: DB_CONFIG, useValue: dbConfig },
682
429
  { provide: DB_SCHEMA, useValue: schema },
@@ -684,70 +431,63 @@ class DbWrapperModule {
684
431
  ]
685
432
  };
686
433
  }
687
- }
688
- DbWrapperModule.decorators = [
689
- { type: NgModule }
690
- ];
691
-
692
- /**
693
- * @fileoverview added by tsickle
694
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
695
- */
696
- /** @enum {string} */
697
- const DataType = {
698
- Integer: 'integer',
699
- Int: 'integer',
700
- TinyInt: 'integer',
701
- SmallInt: 'integer',
702
- BigInt: 'integer',
703
- Text: 'text',
704
- Char: 'text',
705
- NChar: 'text',
706
- VarChar: 'text',
707
- NVarChar: 'text',
708
- CLOB: 'text',
709
- BLOB: 'blob',
710
- Real: 'real',
711
- Double: 'real',
712
- Decimal: 'real',
713
- Float: 'real',
714
- Boolean: 'integer',
715
- DateTime: 'text',
716
- Date: 'text',
717
434
  };
718
- /** @enum {string} */
719
- const DefaultType = {
720
- Integer: '0',
721
- Int: '0',
722
- TinyInt: '0',
723
- SmallInt: '0',
724
- BigInt: '0',
725
- Text: '\'\'',
726
- Char: '\'\'',
727
- NChar: '\'\'',
728
- VarChar: '\'\'',
729
- NVarChar: '\'\'',
730
- CLOB: '\'\'',
731
- BLOB: '0',
732
- Real: '0.0',
733
- Double: '0.0',
734
- Decimal: '0.0',
735
- Float: '0.0',
736
- Boolean: '0',
737
- DateTime: '(datetime(\'now\', \'localtime\'))',
738
- Date: '(date(\'now\', \'localtime\'))',
739
- };
435
+ DbWrapperModule = DbWrapperModule_1 = __decorate([
436
+ NgModule()
437
+ ], DbWrapperModule);
740
438
 
741
- /**
742
- * @fileoverview added by tsickle
743
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
439
+ var DataType;
440
+ (function (DataType) {
441
+ DataType["Integer"] = "integer";
442
+ DataType["Int"] = "integer";
443
+ DataType["TinyInt"] = "integer";
444
+ DataType["SmallInt"] = "integer";
445
+ DataType["BigInt"] = "integer";
446
+ DataType["Text"] = "text";
447
+ DataType["Char"] = "text";
448
+ DataType["NChar"] = "text";
449
+ DataType["VarChar"] = "text";
450
+ DataType["NVarChar"] = "text";
451
+ DataType["CLOB"] = "text";
452
+ DataType["BLOB"] = "blob";
453
+ DataType["Real"] = "real";
454
+ DataType["Double"] = "real";
455
+ DataType["Decimal"] = "real";
456
+ DataType["Float"] = "real";
457
+ DataType["Boolean"] = "integer";
458
+ DataType["DateTime"] = "text";
459
+ DataType["Date"] = "text";
460
+ })(DataType || (DataType = {}));
461
+ var DefaultType;
462
+ (function (DefaultType) {
463
+ DefaultType["Integer"] = "0";
464
+ DefaultType["Int"] = "0";
465
+ DefaultType["TinyInt"] = "0";
466
+ DefaultType["SmallInt"] = "0";
467
+ DefaultType["BigInt"] = "0";
468
+ DefaultType["Text"] = "''";
469
+ DefaultType["Char"] = "''";
470
+ DefaultType["NChar"] = "''";
471
+ DefaultType["VarChar"] = "''";
472
+ DefaultType["NVarChar"] = "''";
473
+ DefaultType["CLOB"] = "''";
474
+ DefaultType["BLOB"] = "0";
475
+ DefaultType["Real"] = "0.0";
476
+ DefaultType["Double"] = "0.0";
477
+ DefaultType["Decimal"] = "0.0";
478
+ DefaultType["Float"] = "0.0";
479
+ DefaultType["Boolean"] = "0";
480
+ DefaultType["DateTime"] = "(datetime('now', 'localtime'))";
481
+ DefaultType["Date"] = "(date('now', 'localtime'))";
482
+ })(DefaultType || (DefaultType = {}));
483
+
484
+ /*
485
+ * Public API Surface of db-wrapper
744
486
  */
745
487
 
746
488
  /**
747
- * @fileoverview added by tsickle
748
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
489
+ * Generated bundle index. Do not edit.
749
490
  */
750
491
 
751
- export { getDefaultDbConfig, provideDbWrapper, DbWrapperService, DB_CONFIG, DB_SCHEMA, DbWrapperModule, DataType, DefaultType };
752
-
753
- //# sourceMappingURL=db-wrapper.js.map
492
+ export { DB_CONFIG, DB_SCHEMA, DataType, DbWrapperModule, DbWrapperService, DefaultType, getDefaultDbConfig, provideDbWrapper };
493
+ //# sourceMappingURL=db-wrapper.js.map