@@ -18,10 +18,7 @@ describe('Bulk', function () {
18
18
let client : MongoClient ;
19
19
20
20
beforeEach ( async function ( ) {
21
- client = this . configuration . newClient ( this . configuration . writeConcernMax ( ) , {
22
- maxPoolSize : 1 ,
23
- monitorCommands : true
24
- } ) ;
21
+ client = this . configuration . newClient ( { } , { maxPoolSize : 1 , monitorCommands : true } ) ;
25
22
26
23
// TODO(NODE-4192): Not all operations support auto connect
27
24
await client . db ( ) . command ( { ping : 1 } ) ;
@@ -498,7 +495,7 @@ describe('Bulk', function () {
498
495
} ,
499
496
500
497
test : function ( done ) {
501
- client . connect ( function ( err , client ) {
498
+ client . connect ( ( err , client ) => {
502
499
const db = client . db ( ) ;
503
500
const col = db . collection ( 'batch_write_ordered_ops_8' ) ;
504
501
const batch = col . initializeOrderedBulkOp ( ) ;
@@ -536,7 +533,7 @@ describe('Bulk', function () {
536
533
} ,
537
534
538
535
test : function ( done ) {
539
- client . connect ( function ( err , client ) {
536
+ client . connect ( ( err , client ) => {
540
537
const db = client . db ( ) ;
541
538
const col = db . collection ( 'batch_write_ordered_ops_8' ) ;
542
539
@@ -551,7 +548,7 @@ describe('Bulk', function () {
551
548
} ) ;
552
549
553
550
it ( 'should correctly execute ordered batch using w:0' , function ( done ) {
554
- client . connect ( function ( err , client ) {
551
+ client . connect ( ( err , client ) => {
555
552
const db = client . db ( ) ;
556
553
const col = db . collection ( 'batch_write_ordered_ops_9' ) ;
557
554
@@ -578,7 +575,7 @@ describe('Bulk', function () {
578
575
} ) ;
579
576
580
577
it ( 'should correctly handle single unordered batch API' , function ( done ) {
581
- client . connect ( function ( err , client ) {
578
+ client . connect ( ( err , client ) => {
582
579
const db = client . db ( ) ;
583
580
const col = db . collection ( 'batch_write_unordered_ops_legacy_1' ) ;
584
581
@@ -680,7 +677,7 @@ describe('Bulk', function () {
680
677
metadata : { requires : { topology : [ 'single' , 'replicaset' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
681
678
682
679
test : function ( done ) {
683
- client . connect ( function ( err , client ) {
680
+ client . connect ( ( err , client ) => {
684
681
const db = client . db ( ) ;
685
682
const coll = db . collection ( 'batch_write_unordered_ops_legacy_3' ) ;
686
683
// Set up a giant string to blow through the max message size
@@ -709,7 +706,7 @@ describe('Bulk', function () {
709
706
metadata : { requires : { topology : [ 'single' , 'replicaset' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
710
707
711
708
test : function ( done ) {
712
- client . connect ( function ( err , client ) {
709
+ client . connect ( ( err , client ) => {
713
710
const db = client . db ( ) ;
714
711
const coll = db . collection ( 'batch_write_unordered_ops_legacy_4' ) ;
715
712
@@ -743,12 +740,12 @@ describe('Bulk', function () {
743
740
} ) ;
744
741
745
742
it ( 'should Correctly Execute Unordered Batch with duplicate key errors on updates' , function ( done ) {
746
- client . connect ( function ( err , client ) {
743
+ client . connect ( ( err , client ) => {
747
744
const db = client . db ( ) ;
748
745
const col = db . collection ( 'batch_write_unordered_ops_legacy_6' ) ;
749
746
750
747
// Write concern
751
- const writeConcern = self . configuration . writeConcernMax ( ) ;
748
+ const writeConcern = this . configuration . writeConcernMax ( ) ;
752
749
writeConcern . unique = true ;
753
750
writeConcern . sparse = false ;
754
751
@@ -768,7 +765,7 @@ describe('Bulk', function () {
768
765
batch . insert ( { b : 1 } ) ;
769
766
770
767
// Execute the operations
771
- batch . execute ( self . configuration . writeConcernMax ( ) , function ( err , result ) {
768
+ batch . execute ( { } , function ( err , result ) {
772
769
expect ( err ) . to . exist ;
773
770
expect ( result ) . to . not . exist ;
774
771
@@ -845,12 +842,12 @@ describe('Bulk', function () {
845
842
metadata : { requires : { topology : [ 'single' , 'replicaset' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
846
843
847
844
test : function ( done ) {
848
- client . connect ( function ( err , client ) {
845
+ client . connect ( ( err , client ) => {
849
846
const db = client . db ( ) ;
850
847
const col = db . collection ( 'batch_write_unordered_ops_legacy_7' ) ;
851
848
852
849
// Add unique index on b field causing all updates to fail
853
- col . createIndex ( { b : 1 } , { unique : true , sparse : false } , function ( err ) {
850
+ col . createIndex ( { b : 1 } , { unique : true , sparse : false } , err => {
854
851
expect ( err ) . to . not . exist ;
855
852
856
853
// Initialize the unordered Batch
@@ -871,7 +868,7 @@ describe('Bulk', function () {
871
868
batch . insert ( { b : 1 } ) ;
872
869
873
870
// Execute the operations
874
- batch . execute ( self . configuration . writeConcernMax ( ) , function ( err , result ) {
871
+ batch . execute ( { } , function ( err , result ) {
875
872
expect ( err ) . to . exist ;
876
873
expect ( result ) . to . not . exist ;
877
874
@@ -906,47 +903,43 @@ describe('Bulk', function () {
906
903
}
907
904
) ;
908
905
909
- it ( 'should correctly perform unordered upsert with custom _id' , {
910
- metadata : { requires : { topology : [ 'single' , 'replicaset' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
911
-
912
- test : function ( done ) {
913
- client . connect ( function ( err , client ) {
914
- const db = client . db ( ) ;
915
- const col = db . collection ( 'batch_write_unordered_ops_legacy_8' ) ;
916
- const batch = col . initializeUnorderedBulkOp ( ) ;
906
+ it ( 'should correctly perform unordered upsert with custom _id' , function ( done ) {
907
+ client . connect ( ( err , client ) => {
908
+ const db = client . db ( ) ;
909
+ const col = db . collection ( 'batch_write_unordered_ops_legacy_8' ) ;
910
+ const batch = col . initializeUnorderedBulkOp ( ) ;
917
911
918
- // Add some operations to be executed in order
919
- batch
920
- . find ( { _id : 2 } )
921
- . upsert ( )
922
- . updateOne ( { $set : { b : 2 } } ) ;
912
+ // Add some operations to be executed in order
913
+ batch
914
+ . find ( { _id : 2 } )
915
+ . upsert ( )
916
+ . updateOne ( { $set : { b : 2 } } ) ;
923
917
924
- // Execute the operations
925
- batch . execute ( self . configuration . writeConcernMax ( ) , function ( err , result ) {
926
- // Check state of result
927
- test . equal ( 1 , result . nUpserted ) ;
928
- test . equal ( 0 , result . nInserted ) ;
929
- test . equal ( 0 , result . nMatched ) ;
930
- test . ok ( 0 === result . nModified || result . nModified == null ) ;
931
- test . equal ( 0 , result . nRemoved ) ;
918
+ // Execute the operations
919
+ batch . execute ( { } , function ( err , result ) {
920
+ // Check state of result
921
+ test . equal ( 1 , result . nUpserted ) ;
922
+ test . equal ( 0 , result . nInserted ) ;
923
+ test . equal ( 0 , result . nMatched ) ;
924
+ test . ok ( 0 === result . nModified || result . nModified == null ) ;
925
+ test . equal ( 0 , result . nRemoved ) ;
932
926
933
- const upserts = result . getUpsertedIds ( ) ;
934
- test . equal ( 1 , upserts . length ) ;
935
- test . equal ( 0 , upserts [ 0 ] . index ) ;
936
- test . equal ( 2 , upserts [ 0 ] . _id ) ;
927
+ const upserts = result . getUpsertedIds ( ) ;
928
+ test . equal ( 1 , upserts . length ) ;
929
+ test . equal ( 0 , upserts [ 0 ] . index ) ;
930
+ test . equal ( 2 , upserts [ 0 ] . _id ) ;
937
931
938
- // Finish up test
939
- client . close ( done ) ;
940
- } ) ;
932
+ // Finish up test
933
+ client . close ( done ) ;
941
934
} ) ;
942
- }
935
+ } ) ;
943
936
} ) ;
944
937
945
938
it ( 'should prohibit batch finds with no selector' , {
946
939
metadata : { requires : { topology : [ 'single' , 'replicaset' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
947
940
948
941
test : function ( done ) {
949
- client . connect ( function ( err , client ) {
942
+ client . connect ( ( err , client ) => {
950
943
expect ( err ) . to . not . exist ;
951
944
952
945
const db = client . db ( ) ;
@@ -978,18 +971,16 @@ describe('Bulk', function () {
978
971
metadata : { requires : { topology : [ 'single' , 'replicaset' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
979
972
980
973
test : function ( done ) {
981
- client . connect ( function ( err , client ) {
974
+ client . connect ( ( err , client ) => {
982
975
const db = client . db ( ) ;
983
976
const col = db . collection ( 'batch_write_ordered_ops_8' ) ;
984
977
985
- col
986
- . initializeUnorderedBulkOp ( )
987
- . execute ( self . configuration . writeConcernMax ( ) , function ( err ) {
988
- expect ( err ) . to . be . instanceOf ( MongoDriverError ) ;
989
- expect ( err ) . to . have . property ( 'message' , 'Invalid BulkOperation, Batch cannot be empty' ) ;
978
+ col . initializeUnorderedBulkOp ( ) . execute ( { } , function ( err ) {
979
+ expect ( err ) . to . be . instanceOf ( MongoDriverError ) ;
980
+ expect ( err ) . to . have . property ( 'message' , 'Invalid BulkOperation, Batch cannot be empty' ) ;
990
981
991
- client . close ( done ) ;
992
- } ) ;
982
+ client . close ( done ) ;
983
+ } ) ;
993
984
} ) ;
994
985
}
995
986
} ) ;
@@ -998,7 +989,7 @@ describe('Bulk', function () {
998
989
metadata : { requires : { topology : [ 'single' , 'replicaset' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
999
990
1000
991
test : function ( done ) {
1001
- client . connect ( function ( err , client ) {
992
+ client . connect ( ( err , client ) => {
1002
993
const db = client . db ( ) ;
1003
994
const col = db . collection ( 'batch_write_ordered_ops_9' ) ;
1004
995
const bulk = col . initializeUnorderedBulkOp ( ) ;
@@ -1025,7 +1016,7 @@ describe('Bulk', function () {
1025
1016
} ) ;
1026
1017
1027
1018
it ( 'should provide an accessor for operations on ordered bulk ops' , function ( done ) {
1028
- client . connect ( function ( err , client ) {
1019
+ client . connect ( ( err , client ) => {
1029
1020
const db = client . db ( ) ;
1030
1021
const col = db . collection ( 'bulk_get_operations_test' ) ;
1031
1022
@@ -1053,7 +1044,7 @@ describe('Bulk', function () {
1053
1044
metadata : { requires : { topology : 'single' , mongodb : '>2.5.4' } } ,
1054
1045
1055
1046
test : function ( done ) {
1056
- client . connect ( function ( err , client ) {
1047
+ client . connect ( ( err , client ) => {
1057
1048
const db = client . db ( ) ;
1058
1049
const col = db . collection ( 'batch_write_concerns_ops_1' ) ;
1059
1050
const batch = col . initializeOrderedBulkOp ( ) ;
@@ -1082,7 +1073,7 @@ describe('Bulk', function () {
1082
1073
} ,
1083
1074
1084
1075
test : function ( done ) {
1085
- client . connect ( function ( err , client ) {
1076
+ client . connect ( ( err , client ) => {
1086
1077
const db = client . db ( ) ;
1087
1078
const docs = [ ] ;
1088
1079
for ( let i = 0 ; i < 5 ; i ++ ) {
@@ -1106,7 +1097,7 @@ describe('Bulk', function () {
1106
1097
} ) ;
1107
1098
1108
1099
it ( 'should provide an accessor for operations on unordered bulk ops' , function ( done ) {
1109
- client . connect ( function ( err , client ) {
1100
+ client . connect ( ( err , client ) => {
1110
1101
const db = client . db ( ) ;
1111
1102
const col = db . collection ( 'bulk_get_operations_test' ) ;
1112
1103
@@ -1134,7 +1125,7 @@ describe('Bulk', function () {
1134
1125
metadata : { requires : { topology : 'single' , mongodb : '>2.5.4' } } ,
1135
1126
1136
1127
test : function ( done ) {
1137
- client . connect ( function ( err , client ) {
1128
+ client . connect ( ( err , client ) => {
1138
1129
const db = client . db ( ) ;
1139
1130
const col = db . collection ( 'batch_write_concerns_ops_1' ) ;
1140
1131
const batch = col . initializeUnorderedBulkOp ( ) ;
@@ -1156,7 +1147,7 @@ describe('Bulk', function () {
1156
1147
metadata : { requires : { topology : 'single' , mongodb : '>2.5.4' } } ,
1157
1148
1158
1149
test : function ( done ) {
1159
- client . connect ( function ( err , client ) {
1150
+ client . connect ( ( err , client ) => {
1160
1151
const db = client . db ( ) ;
1161
1152
const col = db . collection ( 'batch_write_concerns_ops_1' ) ;
1162
1153
let batch = col . initializeOrderedBulkOp ( ) ;
@@ -1184,7 +1175,7 @@ describe('Bulk', function () {
1184
1175
metadata : { requires : { topology : 'single' , mongodb : '>2.5.4' } } ,
1185
1176
1186
1177
test : function ( done ) {
1187
- client . connect ( function ( err , client ) {
1178
+ client . connect ( ( err , client ) => {
1188
1179
const db = client . db ( ) ;
1189
1180
const insertFirst = false ;
1190
1181
const batchSize = 1000 ;
@@ -1240,7 +1231,7 @@ describe('Bulk', function () {
1240
1231
metadata : { requires : { topology : 'single' , mongodb : '>2.5.4' } } ,
1241
1232
1242
1233
test : function ( done ) {
1243
- client . connect ( function ( err , client ) {
1234
+ client . connect ( ( err , client ) => {
1244
1235
const db = client . db ( ) ;
1245
1236
const insertFirst = false ;
1246
1237
const batchSize = 1000 ;
@@ -1302,7 +1293,7 @@ describe('Bulk', function () {
1302
1293
} ,
1303
1294
1304
1295
test : function ( done ) {
1305
- client . connect ( function ( err , client ) {
1296
+ client . connect ( ( err , client ) => {
1306
1297
const db = client . db ( ) ;
1307
1298
const docs = [ ] ;
1308
1299
for ( let i = 0 ; i < 5 ; i ++ ) {
@@ -1340,7 +1331,7 @@ describe('Bulk', function () {
1340
1331
{
1341
1332
metadata : { requires : { mongodb : '>=2.6.0' , topology : 'single' } } ,
1342
1333
test : function ( done ) {
1343
- client . connect ( function ( err , client ) {
1334
+ client . connect ( ( err , client ) => {
1344
1335
const db = client . db ( ) ;
1345
1336
db . collection ( 'doesnt_matter' ) . insertMany ( [ ] , { ordered : false } , function ( err ) {
1346
1337
expect ( err ) . to . be . instanceOf ( MongoDriverError ) ;
0 commit comments