@@ -32,17 +32,17 @@ const should = require('should');
32
32
const dbconfig = require ( './dbconfig.js' ) ;
33
33
const sodaUtil = require ( './sodaUtil.js' ) ;
34
34
35
+ const t_contents = [
36
+ { id : 1001 , name : "Gillian" , office : "Shenzhen" } ,
37
+ { id : 1002 , name : "Chris" , office : "Melbourne" } ,
38
+ { id : 1003 , name : "Changjie" , office : "Shenzhen" } ,
39
+ { id : 1004 , name : "Venkat" , office : "Bangalore" } ,
40
+ { id : 1005 , name : "May" , office : "London" } ,
41
+ { id : 1006 , name : "Joe" , office : "San Francisco" } ,
42
+ { id : 1007 , name : "Gavin" , office : "New York" }
43
+ ] ;
44
+
35
45
describe ( '173. soda5.js' , ( ) => {
36
-
37
- const t_contents = [
38
- { id : 1001 , name : "Gillian" , office : "Shenzhen" } ,
39
- { id : 1002 , name : "Chris" , office : "Melbourne" } ,
40
- { id : 1003 , name : "Changjie" , office : "Shenzhen" } ,
41
- { id : 1004 , name : "Venkat" , office : "Bangalore" } ,
42
- { id : 1005 , name : "May" , office : "London" } ,
43
- { id : 1006 , name : "Joe" , office : "San Francisco" } ,
44
- { id : 1007 , name : "Gavin" , office : "New York" }
45
- ] ;
46
46
47
47
before ( async function ( ) {
48
48
const runnable = await sodaUtil . checkPrerequisites ( ) ;
@@ -76,7 +76,7 @@ describe('173. soda5.js', () => {
76
76
return collection . insertOne ( content ) ;
77
77
} )
78
78
) ;
79
-
79
+
80
80
// Fetch back
81
81
let empInShenzhen = await collection . find ( )
82
82
. filter ( { "office" : { "$like" : "Shenzhen" } } )
@@ -141,13 +141,13 @@ describe('173. soda5.js', () => {
141
141
} catch ( err ) {
142
142
should . not . exist ( err ) ;
143
143
}
144
-
144
+
145
145
try {
146
146
await conn . commit ( ) ;
147
- }
147
+ }
148
148
catch ( err ) {
149
149
should . not . exist ( err ) ;
150
- }
150
+ }
151
151
152
152
if ( collection ) {
153
153
let res = await collection . drop ( ) ;
@@ -169,7 +169,7 @@ describe('173. soda5.js', () => {
169
169
170
170
let soda = conn . getSodaDatabase ( ) ;
171
171
collection = await soda . createCollection ( "soda_test_173_3" ) ;
172
-
172
+
173
173
} catch ( err ) {
174
174
should . not . exist ( err ) ;
175
175
}
@@ -204,7 +204,7 @@ describe('173. soda5.js', () => {
204
204
205
205
let soda = conn . getSodaDatabase ( ) ;
206
206
collection = await soda . createCollection ( "soda_test_173_4" ) ;
207
-
207
+
208
208
} catch ( err ) {
209
209
should . not . exist ( err ) ;
210
210
}
@@ -312,7 +312,7 @@ describe('173. soda5.js', () => {
312
312
return collection . insertOne ( content ) ;
313
313
} )
314
314
) ;
315
-
315
+
316
316
// Fetch back
317
317
let empInShenzhen = await collection . find ( )
318
318
. filter ( { "office" : { "$like" : "Shenzhen" } } )
@@ -371,7 +371,7 @@ describe('173. soda5.js', () => {
371
371
// drop index
372
372
let indexName = indexSpec . name ;
373
373
await collection . dropIndex ( indexName ) ;
374
-
374
+
375
375
// Fetch back
376
376
let empInShenzhen = await collection . find ( )
377
377
. filter ( { "office" : { "$like" : "Shenzhen" } } )
@@ -422,7 +422,7 @@ describe('173. soda5.js', () => {
422
422
return collection . insertOne ( content ) ;
423
423
} )
424
424
) ;
425
-
425
+
426
426
// Fetch back
427
427
let empInShenzhen = await collection . find ( )
428
428
. filter ( { "office" : { "$like" : "Shenzhen" } } )
@@ -478,7 +478,7 @@ describe('173. soda5.js', () => {
478
478
return collection . insertOne ( content ) ;
479
479
} )
480
480
) ;
481
-
481
+
482
482
// Fetch back
483
483
let empInShenzhen = await collection . find ( )
484
484
. filter ( { "office" : { "$like" : "Shenzhen" } } )
@@ -510,4 +510,70 @@ describe('173. soda5.js', () => {
510
510
}
511
511
}
512
512
} ) ; // 173.10
513
- } ) ;
513
+
514
+ it ( '173.11 option object of dropIndex(), basic case' , async ( ) => {
515
+ let options = { "force" : true } ;
516
+ await dropIdxOpt ( options ) ;
517
+ } ) ; // 173.11
518
+
519
+ it ( '173.12 option object of dropIndex(), boolean value is false' , async ( ) => {
520
+ let options = { "force" : false } ;
521
+ await dropIdxOpt ( options ) ;
522
+ } ) ; // 173.12
523
+
524
+ } ) ;
525
+
526
+ const dropIdxOpt = async function ( opts ) {
527
+ let conn , collection ;
528
+ try {
529
+ conn = await oracledb . getConnection ( dbconfig ) ;
530
+
531
+ let soda = conn . getSodaDatabase ( ) ;
532
+ collection = await soda . createCollection ( "soda_test_173_7" ) ;
533
+
534
+ let indexSpec = {
535
+ "name" : "OFFICE_IDX" ,
536
+ "fields" : [
537
+ {
538
+ "path" : "office" ,
539
+ "datatype" : "string" ,
540
+ "order" : "asc"
541
+ }
542
+ ]
543
+ } ;
544
+ await collection . createIndex ( indexSpec ) ;
545
+
546
+ await Promise . all (
547
+ t_contents . map ( function ( content ) {
548
+ return collection . insertOne ( content ) ;
549
+ } )
550
+ ) ;
551
+
552
+ // Fetch back
553
+ let empInShenzhen = await collection . find ( )
554
+ . filter ( { "office" : { "$like" : "Shenzhen" } } )
555
+ . count ( ) ;
556
+ should . strictEqual ( empInShenzhen . count , 2 ) ;
557
+
558
+ // drop index
559
+ let indexName = indexSpec . name ;
560
+ await collection . dropIndex ( indexName , opts ) ;
561
+
562
+ await conn . commit ( ) ;
563
+
564
+ } catch ( err ) {
565
+ should . noConflict . exist ( err ) ;
566
+ } finally {
567
+ if ( collection ) {
568
+ let res = await collection . drop ( ) ;
569
+ should . strictEqual ( res . dropped , true ) ;
570
+ }
571
+ if ( conn ) {
572
+ try {
573
+ await conn . close ( ) ;
574
+ } catch ( err ) {
575
+ should . not . exist ( err ) ;
576
+ }
577
+ }
578
+ }
579
+ } ;
0 commit comments