@@ -51,48 +51,25 @@ module.exports =
51
51
52
52
var _createClass = ( function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( 'value' in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ) ( ) ;
53
53
54
- function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { 'default' : obj } ; }
55
-
56
54
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( 'Cannot call a class as a function' ) ; } }
57
55
58
- var _rethinkdbdash = __webpack_require__ ( 1 ) ;
59
-
60
- var _rethinkdbdash2 = _interopRequireDefault ( _rethinkdbdash ) ;
61
-
62
- var _jsData = __webpack_require__ ( 2 ) ;
63
-
64
- var _jsData2 = _interopRequireDefault ( _jsData ) ;
65
-
66
- var _moutObjectKeys = __webpack_require__ ( 3 ) ;
67
-
68
- var _moutObjectKeys2 = _interopRequireDefault ( _moutObjectKeys ) ;
69
-
70
- var _moutLangIsEmpty = __webpack_require__ ( 4 ) ;
71
-
72
- var _moutLangIsEmpty2 = _interopRequireDefault ( _moutLangIsEmpty ) ;
73
-
74
- var _moutStringUpperCase = __webpack_require__ ( 5 ) ;
75
-
76
- var _moutStringUpperCase2 = _interopRequireDefault ( _moutStringUpperCase ) ;
77
-
78
- var _moutStringUnderscore = __webpack_require__ ( 6 ) ;
79
-
80
- var _moutStringUnderscore2 = _interopRequireDefault ( _moutStringUnderscore ) ;
81
-
82
- var _moutObjectOmit = __webpack_require__ ( 7 ) ;
83
-
84
- var _moutObjectOmit2 = _interopRequireDefault ( _moutObjectOmit ) ;
85
-
86
- var DSUtils = _jsData2 [ 'default' ] . DSUtils ;
87
- var P = DSUtils . Promise ;
56
+ var rethinkdbdash = __webpack_require__ ( 1 ) ;
57
+ var JSData = __webpack_require__ ( 2 ) ;
58
+ var DSUtils = JSData . DSUtils ;
59
+ var upperCase = DSUtils . upperCase ;
88
60
var contains = DSUtils . contains ;
89
61
var forOwn = DSUtils . forOwn ;
62
+ var isEmpty = DSUtils . isEmpty ;
63
+ var keys = DSUtils . keys ;
90
64
var deepMixIn = DSUtils . deepMixIn ;
91
65
var forEach = DSUtils . forEach ;
92
66
var isObject = DSUtils . isObject ;
93
67
var isArray = DSUtils . isArray ;
94
68
var isString = DSUtils . isString ;
95
69
var removeCircular = DSUtils . removeCircular ;
70
+ var omit = DSUtils . omit ;
71
+
72
+ var underscore = __webpack_require__ ( 3 ) ;
96
73
97
74
var Defaults = function Defaults ( ) {
98
75
_classCallCheck ( this , Defaults ) ;
@@ -115,7 +92,7 @@ module.exports =
115
92
options = options || { } ;
116
93
this . defaults = new Defaults ( ) ;
117
94
deepMixIn ( this . defaults , options ) ;
118
- this . r = ( 0 , _rethinkdbdash2 [ 'default' ] ) ( this . defaults ) ;
95
+ this . r = rethinkdbdash ( this . defaults ) ;
119
96
this . databases = { } ;
120
97
this . tables = { } ;
121
98
this . indices = { } ;
@@ -124,7 +101,7 @@ module.exports =
124
101
_createClass ( DSRethinkDBAdapter , [ {
125
102
key : 'selectTable' ,
126
103
value : function selectTable ( resourceConfig , options ) {
127
- return this . r . db ( options . db || this . defaults . db ) . table ( resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) ) ;
104
+ return this . r . db ( options . db || this . defaults . db ) . table ( resourceConfig . table || underscore ( resourceConfig . name ) ) ;
128
105
}
129
106
} , {
130
107
key : 'filterSequence' ,
@@ -135,7 +112,7 @@ module.exports =
135
112
params . orderBy = params . orderBy || params . sort ;
136
113
params . skip = params . skip || params . offset ;
137
114
138
- forEach ( ( 0 , _moutObjectKeys2 [ 'default' ] ) ( params ) , function ( k ) {
115
+ forEach ( keys ( params ) , function ( k ) {
139
116
var v = params [ k ] ;
140
117
if ( ! contains ( reserved , k ) ) {
141
118
if ( isObject ( v ) ) {
@@ -151,7 +128,7 @@ module.exports =
151
128
152
129
var query = sequence ;
153
130
154
- if ( ! ( 0 , _moutLangIsEmpty2 [ 'default' ] ) ( params . where ) ) {
131
+ if ( ! isEmpty ( params . where ) ) {
155
132
query = query . filter ( function ( row ) {
156
133
var subQuery = undefined ;
157
134
forOwn ( params . where , function ( criteria , field ) {
@@ -216,7 +193,7 @@ module.exports =
216
193
if ( isString ( params . orderBy [ i ] ) ) {
217
194
params . orderBy [ i ] = [ params . orderBy [ i ] , 'asc' ] ;
218
195
}
219
- query = ( 0 , _moutStringUpperCase2 [ 'default' ] ) ( params . orderBy [ i ] [ 1 ] ) === 'DESC' ? query . orderBy ( r . desc ( params . orderBy [ i ] [ 0 ] ) ) : query . orderBy ( params . orderBy [ i ] [ 0 ] ) ;
196
+ query = upperCase ( params . orderBy [ i ] [ 1 ] ) === 'DESC' ? query . orderBy ( r . desc ( params . orderBy [ i ] [ 0 ] ) ) : query . orderBy ( params . orderBy [ i ] [ 0 ] ) ;
220
197
}
221
198
}
222
199
@@ -284,23 +261,23 @@ module.exports =
284
261
var models = { } ;
285
262
var merge = { } ;
286
263
options = options || { } ;
287
- var table = resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) ;
264
+ var table = resourceConfig . table || underscore ( resourceConfig . name ) ;
288
265
var tasks = [ this . waitForTable ( table , options ) ] ;
289
266
forEach ( resourceConfig . relationList , function ( def ) {
290
267
var relationName = def . relation ;
291
268
var relationDef = resourceConfig . getResource ( relationName ) ;
292
269
if ( ! relationDef ) {
293
- throw new _jsData2 [ 'default' ] . DSErrors . NER ( relationName ) ;
270
+ throw new JSData . DSErrors . NER ( relationName ) ;
294
271
} else if ( ! options [ 'with' ] || ! contains ( options [ 'with' ] , relationName ) ) {
295
272
return ;
296
273
}
297
274
if ( def . foreignKey ) {
298
- tasks . push ( _this3 . waitForIndex ( relationDef . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( relationDef . name ) , def . foreignKey , options ) ) ;
275
+ tasks . push ( _this3 . waitForIndex ( relationDef . table || underscore ( relationDef . name ) , def . foreignKey , options ) ) ;
299
276
} else if ( def . localKey ) {
300
- tasks . push ( _this3 . waitForIndex ( resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) , def . localKey , options ) ) ;
277
+ tasks . push ( _this3 . waitForIndex ( resourceConfig . table || underscore ( resourceConfig . name ) , def . localKey , options ) ) ;
301
278
}
302
279
} ) ;
303
- return P . all ( tasks ) . then ( function ( ) {
280
+ return DSUtils . Promise . all ( tasks ) . then ( function ( ) {
304
281
return _this3 . r [ 'do' ] ( _this3 . r . table ( table ) . get ( id ) , function ( doc ) {
305
282
forEach ( resourceConfig . relationList , function ( def ) {
306
283
var relationName = def . relation ;
@@ -309,26 +286,26 @@ module.exports =
309
286
return ;
310
287
}
311
288
if ( ! models [ relationName ] ) {
312
- throw new _jsData2 [ 'default' ] . DSErrors . NER ( relationName ) ;
289
+ throw new JSData . DSErrors . NER ( relationName ) ;
313
290
}
314
291
var localKey = def . localKey ;
315
292
var localField = def . localField ;
316
293
var foreignKey = def . foreignKey ;
317
294
if ( def . type === 'belongsTo' ) {
318
- merge [ localField ] = _this3 . r . table ( models [ relationName ] . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( models [ relationName ] . name ) ) . get ( doc ( localKey ) [ 'default' ] ( '' ) ) ;
295
+ merge [ localField ] = _this3 . r . table ( models [ relationName ] . table || underscore ( models [ relationName ] . name ) ) . get ( doc ( localKey ) [ 'default' ] ( '' ) ) ;
319
296
newModels [ localField ] = {
320
297
modelName : relationName ,
321
298
relation : 'belongsTo'
322
299
} ;
323
300
} else if ( def . type === 'hasMany' ) {
324
- merge [ localField ] = _this3 . r . table ( models [ relationName ] . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( models [ relationName ] . name ) ) . getAll ( id , { index : foreignKey } ) . coerceTo ( 'ARRAY' ) ;
301
+ merge [ localField ] = _this3 . r . table ( models [ relationName ] . table || underscore ( models [ relationName ] . name ) ) . getAll ( id , { index : foreignKey } ) . coerceTo ( 'ARRAY' ) ;
325
302
326
303
newModels [ localField ] = {
327
304
modelName : relationName ,
328
305
relation : 'hasMany'
329
306
} ;
330
307
} else if ( def . type === 'hasOne' ) {
331
- merge [ localField ] = _this3 . r . table ( models [ relationName ] . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( models [ relationName ] . name ) ) ;
308
+ merge [ localField ] = _this3 . r . table ( models [ relationName ] . table || underscore ( models [ relationName ] . name ) ) ;
332
309
333
310
if ( localKey ) {
334
311
merge [ localField ] = merge [ localField ] . get ( localKey ) ;
@@ -343,14 +320,14 @@ module.exports =
343
320
}
344
321
} ) ;
345
322
346
- if ( ! ( 0 , _moutLangIsEmpty2 [ 'default' ] ) ( merge ) ) {
323
+ if ( ! isEmpty ( merge ) ) {
347
324
return doc . merge ( merge ) ;
348
325
}
349
326
return doc ;
350
327
} ) . run ( ) ;
351
328
} ) . then ( function ( item ) {
352
329
if ( ! item ) {
353
- return P . reject ( new Error ( 'Not Found!' ) ) ;
330
+ return DSUtils . Promise . reject ( new Error ( 'Not Found!' ) ) ;
354
331
} else {
355
332
forOwn ( item , function ( localValue , localKey ) {
356
333
if ( localKey in newModels ) {
@@ -375,7 +352,7 @@ module.exports =
375
352
var _this4 = this ;
376
353
377
354
options = options || { } ;
378
- var table = resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) ;
355
+ var table = resourceConfig . table || underscore ( resourceConfig . name ) ;
379
356
var tasks = [ this . waitForTable ( table , options ) ] ;
380
357
var models = { } ;
381
358
var merge = { } ;
@@ -384,17 +361,17 @@ module.exports =
384
361
var relationName = def . relation ;
385
362
var relationDef = resourceConfig . getResource ( relationName ) ;
386
363
if ( ! relationDef ) {
387
- throw new _jsData2 [ 'default' ] . DSErrors . NER ( relationName ) ;
364
+ throw new JSData . DSErrors . NER ( relationName ) ;
388
365
} else if ( ! options [ 'with' ] || ! contains ( options [ 'with' ] , relationName ) ) {
389
366
return ;
390
367
}
391
368
if ( def . foreignKey ) {
392
- tasks . push ( _this4 . waitForIndex ( relationDef . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( relationDef . name ) , def . foreignKey , options ) ) ;
369
+ tasks . push ( _this4 . waitForIndex ( relationDef . table || underscore ( relationDef . name ) , def . foreignKey , options ) ) ;
393
370
} else if ( def . localKey ) {
394
- tasks . push ( _this4 . waitForIndex ( resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) , def . localKey , options ) ) ;
371
+ tasks . push ( _this4 . waitForIndex ( resourceConfig . table || underscore ( resourceConfig . name ) , def . localKey , options ) ) ;
395
372
}
396
373
} ) ;
397
- return P . all ( tasks ) . then ( function ( ) {
374
+ return DSUtils . Promise . all ( tasks ) . then ( function ( ) {
398
375
var query = _this4 . filterSequence ( _this4 . selectTable ( resourceConfig , options ) , params ) ;
399
376
if ( options [ 'with' ] && options [ 'with' ] . length ) {
400
377
query = query . map ( function ( doc ) {
@@ -406,26 +383,26 @@ module.exports =
406
383
return ;
407
384
}
408
385
if ( ! models [ relationName ] ) {
409
- throw new _jsData2 [ 'default' ] . DSErrors . NER ( relationName ) ;
386
+ throw new JSData . DSErrors . NER ( relationName ) ;
410
387
}
411
388
var localKey = def . localKey ;
412
389
var localField = def . localField ;
413
390
var foreignKey = def . foreignKey ;
414
391
if ( def . type === 'belongsTo' ) {
415
- merge [ localField ] = _this4 . r . table ( models [ relationName ] . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( models [ relationName ] . name ) ) . get ( doc ( localKey ) [ 'default' ] ( '' ) ) ;
392
+ merge [ localField ] = _this4 . r . table ( models [ relationName ] . table || underscore ( models [ relationName ] . name ) ) . get ( doc ( localKey ) [ 'default' ] ( '' ) ) ;
416
393
newModels [ localField ] = {
417
394
modelName : relationName ,
418
395
relation : 'belongsTo'
419
396
} ;
420
397
} else if ( def . type === 'hasMany' ) {
421
- merge [ localField ] = _this4 . r . table ( models [ relationName ] . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( models [ relationName ] . name ) ) . getAll ( id , { index : foreignKey } ) . coerceTo ( 'ARRAY' ) ;
398
+ merge [ localField ] = _this4 . r . table ( models [ relationName ] . table || underscore ( models [ relationName ] . name ) ) . getAll ( id , { index : foreignKey } ) . coerceTo ( 'ARRAY' ) ;
422
399
423
400
newModels [ localField ] = {
424
401
modelName : relationName ,
425
402
relation : 'hasMany'
426
403
} ;
427
404
} else if ( def . type === 'hasOne' ) {
428
- merge [ localField ] = _this4 . r . table ( models [ relationName ] . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( models [ relationName ] . name ) ) ;
405
+ merge [ localField ] = _this4 . r . table ( models [ relationName ] . table || underscore ( models [ relationName ] . name ) ) ;
429
406
430
407
if ( localKey ) {
431
408
merge [ localField ] = merge [ localField ] . get ( localKey ) ;
@@ -440,7 +417,7 @@ module.exports =
440
417
}
441
418
} ) ;
442
419
443
- if ( ! ( 0 , _moutLangIsEmpty2 [ 'default' ] ) ( merge ) ) {
420
+ if ( ! isEmpty ( merge ) ) {
444
421
return doc . merge ( merge ) ;
445
422
}
446
423
return doc ;
@@ -454,10 +431,10 @@ module.exports =
454
431
value : function create ( resourceConfig , attrs , options ) {
455
432
var _this5 = this ;
456
433
457
- attrs = removeCircular ( ( 0 , _moutObjectOmit2 [ 'default' ] ) ( attrs , resourceConfig . relationFields || [ ] ) ) ;
434
+ attrs = removeCircular ( omit ( attrs , resourceConfig . relationFields || [ ] ) ) ;
458
435
options = options || { } ;
459
- return this . waitForTable ( resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) , options ) . then ( function ( ) {
460
- return _this5 . r . db ( options . db || _this5 . defaults . db ) . table ( resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) ) . insert ( attrs , { returnChanges : true } ) . run ( ) ;
436
+ return this . waitForTable ( resourceConfig . table || underscore ( resourceConfig . name ) , options ) . then ( function ( ) {
437
+ return _this5 . r . db ( options . db || _this5 . defaults . db ) . table ( resourceConfig . table || underscore ( resourceConfig . name ) ) . insert ( attrs , { returnChanges : true } ) . run ( ) ;
461
438
} ) . then ( function ( cursor ) {
462
439
return cursor . changes [ 0 ] . new_val ;
463
440
} ) ;
@@ -467,10 +444,10 @@ module.exports =
467
444
value : function update ( resourceConfig , id , attrs , options ) {
468
445
var _this6 = this ;
469
446
470
- attrs = removeCircular ( ( 0 , _moutObjectOmit2 [ 'default' ] ) ( attrs , resourceConfig . relationFields || [ ] ) ) ;
447
+ attrs = removeCircular ( omit ( attrs , resourceConfig . relationFields || [ ] ) ) ;
471
448
options = options || { } ;
472
- return this . waitForTable ( resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) , options ) . then ( function ( ) {
473
- return _this6 . r . db ( options . db || _this6 . defaults . db ) . table ( resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) ) . get ( id ) . update ( attrs , { returnChanges : true } ) . run ( ) ;
449
+ return this . waitForTable ( resourceConfig . table || underscore ( resourceConfig . name ) , options ) . then ( function ( ) {
450
+ return _this6 . r . db ( options . db || _this6 . defaults . db ) . table ( resourceConfig . table || underscore ( resourceConfig . name ) ) . get ( id ) . update ( attrs , { returnChanges : true } ) . run ( ) ;
474
451
} ) . then ( function ( cursor ) {
475
452
return cursor . changes [ 0 ] . new_val ;
476
453
} ) ;
@@ -480,10 +457,10 @@ module.exports =
480
457
value : function updateAll ( resourceConfig , attrs , params , options ) {
481
458
var _this7 = this ;
482
459
483
- attrs = removeCircular ( ( 0 , _moutObjectOmit2 [ 'default' ] ) ( attrs , resourceConfig . relationFields || [ ] ) ) ;
460
+ attrs = removeCircular ( omit ( attrs , resourceConfig . relationFields || [ ] ) ) ;
484
461
options = options || { } ;
485
462
params = params || { } ;
486
- return this . waitForTable ( resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) , options ) . then ( function ( ) {
463
+ return this . waitForTable ( resourceConfig . table || underscore ( resourceConfig . name ) , options ) . then ( function ( ) {
487
464
return _this7 . filterSequence ( _this7 . selectTable ( resourceConfig , options ) , params ) . update ( attrs , { returnChanges : true } ) . run ( ) ;
488
465
} ) . then ( function ( cursor ) {
489
466
var items = [ ] ;
@@ -499,8 +476,8 @@ module.exports =
499
476
var _this8 = this ;
500
477
501
478
options = options || { } ;
502
- return this . waitForTable ( resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) , options ) . then ( function ( ) {
503
- return _this8 . r . db ( options . db || _this8 . defaults . db ) . table ( resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) ) . get ( id ) [ 'delete' ] ( ) . run ( ) ;
479
+ return this . waitForTable ( resourceConfig . table || underscore ( resourceConfig . name ) , options ) . then ( function ( ) {
480
+ return _this8 . r . db ( options . db || _this8 . defaults . db ) . table ( resourceConfig . table || underscore ( resourceConfig . name ) ) . get ( id ) [ 'delete' ] ( ) . run ( ) ;
504
481
} ) . then ( function ( ) {
505
482
return undefined ;
506
483
} ) ;
@@ -512,7 +489,7 @@ module.exports =
512
489
513
490
options = options || { } ;
514
491
params = params || { } ;
515
- return this . waitForTable ( resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) , options ) . then ( function ( ) {
492
+ return this . waitForTable ( resourceConfig . table || underscore ( resourceConfig . name ) , options ) . then ( function ( ) {
516
493
return _this9 . filterSequence ( _this9 . selectTable ( resourceConfig , options ) , params ) [ 'delete' ] ( ) . run ( ) ;
517
494
} ) . then ( function ( ) {
518
495
return undefined ;
@@ -540,33 +517,9 @@ module.exports =
540
517
541
518
/***/ } ,
542
519
/* 3 */
543
- /***/ function ( module , exports , __webpack_require__ ) {
544
-
545
- module . exports = require ( "mout/object/keys" ) ;
546
-
547
- /***/ } ,
548
- /* 4 */
549
- /***/ function ( module , exports , __webpack_require__ ) {
550
-
551
- module . exports = require ( "mout/lang/isEmpty" ) ;
552
-
553
- /***/ } ,
554
- /* 5 */
555
- /***/ function ( module , exports , __webpack_require__ ) {
556
-
557
- module . exports = require ( "mout/string/upperCase" ) ;
558
-
559
- /***/ } ,
560
- /* 6 */
561
520
/***/ function ( module , exports , __webpack_require__ ) {
562
521
563
522
module . exports = require ( "mout/string/underscore" ) ;
564
523
565
- /***/ } ,
566
- /* 7 */
567
- /***/ function ( module , exports , __webpack_require__ ) {
568
-
569
- module . exports = require ( "mout/object/omit" ) ;
570
-
571
524
/***/ }
572
525
/******/ ] ) ;
0 commit comments