@@ -51,39 +51,19 @@ 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 _mongodb = __webpack_require__ ( 2 ) ;
59
-
60
- var _bson = __webpack_require__ ( 3 ) ;
61
-
62
- var _jsData = __webpack_require__ ( 4 ) ;
63
-
64
- var _jsData2 = _interopRequireDefault ( _jsData ) ;
65
-
66
- var _moutStringUnderscore = __webpack_require__ ( 5 ) ;
67
-
68
- var _moutStringUnderscore2 = _interopRequireDefault ( _moutStringUnderscore ) ;
69
-
70
- var _moutObjectKeys = __webpack_require__ ( 1 ) ;
71
-
72
- var _moutObjectKeys2 = _interopRequireDefault ( _moutObjectKeys ) ;
73
-
74
- var _moutObjectOmit = __webpack_require__ ( 6 ) ;
75
-
76
- var _moutObjectOmit2 = _interopRequireDefault ( _moutObjectOmit ) ;
77
-
78
- var _moutArrayMap = __webpack_require__ ( 7 ) ;
79
-
80
- var _moutArrayMap2 = _interopRequireDefault ( _moutArrayMap ) ;
81
-
82
- var _moutLangIsEmpty = __webpack_require__ ( 8 ) ;
83
-
84
- var _moutLangIsEmpty2 = _interopRequireDefault ( _moutLangIsEmpty ) ;
85
-
86
- var DSUtils = _jsData2 [ 'default' ] . DSUtils ;
56
+ var mongodb = __webpack_require__ ( 1 ) ;
57
+ var MongoClient = mongodb . MongoClient ;
58
+ var bson = __webpack_require__ ( 2 ) ;
59
+ var ObjectID = bson . ObjectID ;
60
+ var JSData = __webpack_require__ ( 3 ) ;
61
+ var underscore = __webpack_require__ ( 4 ) ;
62
+ var map = __webpack_require__ ( 5 ) ;
63
+ var DSUtils = JSData . DSUtils ;
64
+ var keys = DSUtils . keys ;
65
+ var omit = DSUtils . omit ;
66
+ var isEmpty = DSUtils . isEmpty ;
87
67
var deepMixIn = DSUtils . deepMixIn ;
88
68
var forEach = DSUtils . forEach ;
89
69
var contains = DSUtils . contains ;
@@ -111,7 +91,7 @@ module.exports =
111
91
this . defaults = new Defaults ( ) ;
112
92
deepMixIn ( this . defaults , uri ) ;
113
93
this . client = new DSUtils . Promise ( function ( resolve , reject ) {
114
- _mongodb . MongoClient . connect ( uri . uri , function ( err , db ) {
94
+ MongoClient . connect ( uri . uri , function ( err , db ) {
115
95
return err ? reject ( err ) : resolve ( db ) ;
116
96
} ) ;
117
97
} ) ;
@@ -128,7 +108,7 @@ module.exports =
128
108
params = params || { } ;
129
109
params . where = params . where || { } ;
130
110
131
- forEach ( ( 0 , _moutObjectKeys2 [ 'default' ] ) ( params ) , function ( k ) {
111
+ forEach ( keys ( params ) , function ( k ) {
132
112
var v = params [ k ] ;
133
113
if ( ! contains ( reserved , k ) ) {
134
114
if ( isObject ( v ) ) {
@@ -144,7 +124,7 @@ module.exports =
144
124
145
125
var query = { } ;
146
126
147
- if ( ! ( 0 , _moutLangIsEmpty2 [ 'default' ] ) ( params . where ) ) {
127
+ if ( ! isEmpty ( params . where ) ) {
148
128
forOwn ( params . where , function ( criteria , field ) {
149
129
if ( ! isObject ( criteria ) ) {
150
130
params . where [ field ] = {
@@ -303,11 +283,11 @@ module.exports =
303
283
return new DSUtils . Promise ( function ( resolve , reject ) {
304
284
var params = { } ;
305
285
params [ resourceConfig . idAttribute ] = id ;
306
- if ( resourceConfig . idAttribute === '_id' && typeof id === 'string' && _bson . ObjectID . isValid ( id ) ) {
307
- params [ resourceConfig . idAttribute ] = _bson . ObjectID . createFromHexString ( id ) ;
286
+ if ( resourceConfig . idAttribute === '_id' && typeof id === 'string' && ObjectID . isValid ( id ) ) {
287
+ params [ resourceConfig . idAttribute ] = ObjectID . createFromHexString ( id ) ;
308
288
}
309
289
options . fields = options . fields || { } ;
310
- client . collection ( resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) ) . findOne ( params , options , function ( err , r ) {
290
+ client . collection ( resourceConfig . table || underscore ( resourceConfig . name ) ) . findOne ( params , options , function ( err , r ) {
311
291
if ( err ) {
312
292
reject ( err ) ;
313
293
} else if ( ! r ) {
@@ -330,7 +310,7 @@ module.exports =
330
310
return this . getClient ( ) . then ( function ( client ) {
331
311
return new DSUtils . Promise ( function ( resolve , reject ) {
332
312
options . fields = options . fields || { } ;
333
- client . collection ( resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) ) . find ( query , options ) . toArray ( function ( err , r ) {
313
+ client . collection ( resourceConfig . table || underscore ( resourceConfig . name ) ) . find ( query , options ) . toArray ( function ( err , r ) {
334
314
if ( err ) {
335
315
reject ( err ) ;
336
316
} else {
@@ -346,10 +326,10 @@ module.exports =
346
326
var _this3 = this ;
347
327
348
328
options = this . origify ( options ) ;
349
- attrs = removeCircular ( ( 0 , _moutObjectOmit2 [ 'default' ] ) ( attrs , resourceConfig . relationFields || [ ] ) ) ;
329
+ attrs = removeCircular ( omit ( attrs , resourceConfig . relationFields || [ ] ) ) ;
350
330
return this . getClient ( ) . then ( function ( client ) {
351
331
return new DSUtils . Promise ( function ( resolve , reject ) {
352
- var collection = client . collection ( resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) ) ;
332
+ var collection = client . collection ( resourceConfig . table || underscore ( resourceConfig . name ) ) ;
353
333
var method = collection . insertOne ? DSUtils . isArray ( attrs ) ? 'insertMany' : 'insertOne' : 'insert' ;
354
334
collection [ method ] ( attrs , options , function ( err , r ) {
355
335
if ( err ) {
@@ -368,18 +348,18 @@ module.exports =
368
348
value : function update ( resourceConfig , id , attrs , options ) {
369
349
var _this4 = this ;
370
350
371
- attrs = removeCircular ( ( 0 , _moutObjectOmit2 [ 'default' ] ) ( attrs , resourceConfig . relationFields || [ ] ) ) ;
351
+ attrs = removeCircular ( omit ( attrs , resourceConfig . relationFields || [ ] ) ) ;
372
352
options = this . origify ( options ) ;
373
353
return this . find ( resourceConfig , id , options ) . then ( function ( ) {
374
354
return _this4 . getClient ( ) ;
375
355
} ) . then ( function ( client ) {
376
356
return new DSUtils . Promise ( function ( resolve , reject ) {
377
357
var params = { } ;
378
358
params [ resourceConfig . idAttribute ] = id ;
379
- if ( resourceConfig . idAttribute === '_id' && typeof id === 'string' && _bson . ObjectID . isValid ( id ) ) {
380
- params [ resourceConfig . idAttribute ] = _bson . ObjectID . createFromHexString ( id ) ;
359
+ if ( resourceConfig . idAttribute === '_id' && typeof id === 'string' && ObjectID . isValid ( id ) ) {
360
+ params [ resourceConfig . idAttribute ] = ObjectID . createFromHexString ( id ) ;
381
361
}
382
- var collection = client . collection ( resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) ) ;
362
+ var collection = client . collection ( resourceConfig . table || underscore ( resourceConfig . name ) ) ;
383
363
collection [ collection . updateOne ? 'updateOne' : 'update' ] ( params , { $set : attrs } , options , function ( err ) {
384
364
if ( err ) {
385
365
reject ( err ) ;
@@ -398,7 +378,7 @@ module.exports =
398
378
var _this5 = this ;
399
379
400
380
var ids = [ ] ;
401
- attrs = removeCircular ( ( 0 , _moutObjectOmit2 [ 'default' ] ) ( attrs , resourceConfig . relationFields || [ ] ) ) ;
381
+ attrs = removeCircular ( omit ( attrs , resourceConfig . relationFields || [ ] ) ) ;
402
382
options = this . origify ( options ? copy ( options ) : { } ) ;
403
383
var _options = copy ( options ) ;
404
384
_options . multi = true ;
@@ -407,15 +387,15 @@ module.exports =
407
387
queryOptions . $set = attrs ;
408
388
var query = _this5 . getQuery ( resourceConfig , params ) ;
409
389
return _this5 . findAll ( resourceConfig , params , options ) . then ( function ( items ) {
410
- ids = ( 0 , _moutArrayMap2 [ 'default' ] ) ( items , function ( item ) {
390
+ ids = map ( items , function ( item ) {
411
391
var id = item [ resourceConfig . idAttribute ] ;
412
- if ( resourceConfig . idAttribute === '_id' && typeof id === 'string' && _bson . ObjectID . isValid ( id ) ) {
413
- return _bson . ObjectID . createFromHexString ( id ) ;
392
+ if ( resourceConfig . idAttribute === '_id' && typeof id === 'string' && ObjectID . isValid ( id ) ) {
393
+ return ObjectID . createFromHexString ( id ) ;
414
394
}
415
395
return id ;
416
396
} ) ;
417
397
return new DSUtils . Promise ( function ( resolve , reject ) {
418
- var collection = client . collection ( resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) ) ;
398
+ var collection = client . collection ( resourceConfig . table || underscore ( resourceConfig . name ) ) ;
419
399
collection [ collection . updateMany ? 'updateMany' : 'update' ] ( query , queryOptions , _options , function ( err ) {
420
400
if ( err ) {
421
401
reject ( err ) ;
@@ -441,10 +421,10 @@ module.exports =
441
421
return new DSUtils . Promise ( function ( resolve , reject ) {
442
422
var params = { } ;
443
423
params [ resourceConfig . idAttribute ] = id ;
444
- if ( resourceConfig . idAttribute === '_id' && typeof id === 'string' && _bson . ObjectID . isValid ( id ) ) {
445
- params [ resourceConfig . idAttribute ] = _bson . ObjectID . createFromHexString ( id ) ;
424
+ if ( resourceConfig . idAttribute === '_id' && typeof id === 'string' && ObjectID . isValid ( id ) ) {
425
+ params [ resourceConfig . idAttribute ] = ObjectID . createFromHexString ( id ) ;
446
426
}
447
- var collection = client . collection ( resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) ) ;
427
+ var collection = client . collection ( resourceConfig . table || underscore ( resourceConfig . name ) ) ;
448
428
collection [ collection . deleteOne ? 'deleteOne' : 'remove' ] ( params , options , function ( err ) {
449
429
if ( err ) {
450
430
reject ( err ) ;
@@ -465,7 +445,7 @@ module.exports =
465
445
deepMixIn ( options , _this6 . getQueryOptions ( resourceConfig , params ) ) ;
466
446
var query = _this6 . getQuery ( resourceConfig , params ) ;
467
447
return new DSUtils . Promise ( function ( resolve , reject ) {
468
- var collection = client . collection ( resourceConfig . table || ( 0 , _moutStringUnderscore2 [ 'default' ] ) ( resourceConfig . name ) ) ;
448
+ var collection = client . collection ( resourceConfig . table || underscore ( resourceConfig . name ) ) ;
469
449
collection [ collection . deleteMany ? 'deleteMany' : 'remove' ] ( query , options , function ( err ) {
470
450
if ( err ) {
471
451
reject ( err ) ;
@@ -486,51 +466,33 @@ module.exports =
486
466
487
467
/***/ } ,
488
468
/* 1 */
489
- /***/ function ( module , exports , __webpack_require__ ) {
490
-
491
- module . exports = require ( "mout/object/keys" ) ;
492
-
493
- /***/ } ,
494
- /* 2 */
495
- /***/ function ( module , exports , __webpack_require__ ) {
469
+ /***/ function ( module , exports ) {
496
470
497
471
module . exports = require ( "mongodb" ) ;
498
472
499
473
/***/ } ,
500
- /* 3 */
501
- /***/ function ( module , exports , __webpack_require__ ) {
474
+ /* 2 */
475
+ /***/ function ( module , exports ) {
502
476
503
477
module . exports = require ( "bson" ) ;
504
478
505
479
/***/ } ,
506
- /* 4 */
507
- /***/ function ( module , exports , __webpack_require__ ) {
480
+ /* 3 */
481
+ /***/ function ( module , exports ) {
508
482
509
483
module . exports = require ( "js-data" ) ;
510
484
511
485
/***/ } ,
512
- /* 5 */
513
- /***/ function ( module , exports , __webpack_require__ ) {
486
+ /* 4 */
487
+ /***/ function ( module , exports ) {
514
488
515
489
module . exports = require ( "mout/string/underscore" ) ;
516
490
517
491
/***/ } ,
518
- /* 6 */
519
- /***/ function ( module , exports , __webpack_require__ ) {
520
-
521
- module . exports = require ( "mout/object/omit" ) ;
522
-
523
- /***/ } ,
524
- /* 7 */
525
- /***/ function ( module , exports , __webpack_require__ ) {
492
+ /* 5 */
493
+ /***/ function ( module , exports ) {
526
494
527
495
module . exports = require ( "mout/array/map" ) ;
528
496
529
- /***/ } ,
530
- /* 8 */
531
- /***/ function ( module , exports , __webpack_require__ ) {
532
-
533
- module . exports = require ( "mout/lang/isEmpty" ) ;
534
-
535
497
/***/ }
536
498
/******/ ] ) ;
0 commit comments