@@ -44,6 +44,7 @@ NJS_NAPI_METHOD_DECL_ASYNC(njsSodaCollection_insertMany);
44
44
NJS_NAPI_METHOD_DECL_ASYNC (njsSodaCollection_insertManyAndGet );
45
45
NJS_NAPI_METHOD_DECL_ASYNC (njsSodaCollection_insertOne );
46
46
NJS_NAPI_METHOD_DECL_ASYNC (njsSodaCollection_insertOneAndGet );
47
+ NJS_NAPI_METHOD_DECL_ASYNC (njsSodaCollection_listIndexes );
47
48
NJS_NAPI_METHOD_DECL_ASYNC (njsSodaCollection_save );
48
49
NJS_NAPI_METHOD_DECL_ASYNC (njsSodaCollection_saveAndGet );
49
50
NJS_NAPI_METHOD_DECL_ASYNC (njsSodaCollection_truncate );
@@ -57,6 +58,7 @@ static NJS_ASYNC_METHOD(njsSodaCollection_insertManyAsync);
57
58
static NJS_ASYNC_METHOD (njsSodaCollection_insertManyAndGetAsync );
58
59
static NJS_ASYNC_METHOD (njsSodaCollection_insertOneAsync );
59
60
static NJS_ASYNC_METHOD (njsSodaCollection_insertOneAndGetAsync );
61
+ static NJS_ASYNC_METHOD (njsSodaCollection_listIndexesAsync );
60
62
static NJS_ASYNC_METHOD (njsSodaCollection_saveAsync );
61
63
static NJS_ASYNC_METHOD (njsSodaCollection_saveAndGetAsync );
62
64
static NJS_ASYNC_METHOD (njsSodaCollection_truncateAsync );
@@ -67,6 +69,7 @@ static NJS_ASYNC_POST_METHOD(njsSodaCollection_dropIndexPostAsync);
67
69
static NJS_ASYNC_POST_METHOD (njsSodaCollection_getDataGuidePostAsync );
68
70
static NJS_ASYNC_POST_METHOD (njsSodaCollection_insertManyAndGetPostAsync );
69
71
static NJS_ASYNC_POST_METHOD (njsSodaCollection_insertOneAndGetPostAsync );
72
+ static NJS_ASYNC_POST_METHOD (njsSodaCollection_listIndexesPostAsync );
70
73
static NJS_ASYNC_POST_METHOD (njsSodaCollection_saveAndGetPostAsync );
71
74
72
75
// processing arguments methods
@@ -99,6 +102,8 @@ static const napi_property_descriptor njsClassProperties[] = {
99
102
napi_default , NULL },
100
103
{ "getName" , NULL , njsSodaCollection_getName , NULL , NULL , NULL ,
101
104
napi_default , NULL },
105
+ { "listIndexes" , NULL , njsSodaCollection_listIndexes , NULL , NULL , NULL ,
106
+ napi_default , NULL },
102
107
{ "save" , NULL , njsSodaCollection_save , NULL , NULL , NULL , napi_default ,
103
108
NULL },
104
109
{ "saveAndGet" , NULL , njsSodaCollection_saveAndGet , NULL , NULL , NULL ,
@@ -633,6 +638,64 @@ static bool njsSodaCollection_insertOneAndGetPostAsync(njsBaton *baton,
633
638
}
634
639
635
640
641
+
642
+ //-----------------------------------------------------------------------------
643
+ // njsSodaCollection_listIndexes()
644
+ // Obtains a list of indexes from the collection and returns. Each index
645
+ // is an object
646
+ //-----------------------------------------------------------------------------
647
+ NJS_NAPI_METHOD_IMPL_ASYNC (njsSodaCollection_listIndexes , 0 , NULL )
648
+ {
649
+ return njsBaton_queueWork (baton , env , "listIndexes" ,
650
+ njsSodaCollection_listIndexesAsync ,
651
+ njsSodaCollection_listIndexesPostAsync , returnValue );
652
+ }
653
+
654
+
655
+ //-----------------------------------------------------------------------------
656
+ // njsSodaCollection_listIndexesAsync()
657
+ // Worker function for njsSodaCollection_listIndexes().
658
+ //-----------------------------------------------------------------------------
659
+ static bool njsSodaCollection_listIndexesAsync (njsBaton * baton )
660
+ {
661
+ njsSodaCollection * coll = (njsSodaCollection * ) baton -> callingInstance ;
662
+
663
+ baton -> indexList = calloc (1 , sizeof (dpiStringList ));
664
+ if (!baton -> indexList )
665
+ return njsBaton_setErrorInsufficientMemory (baton );
666
+ if (dpiSodaColl_listIndexes (coll -> handle , DPI_SODA_FLAGS_DEFAULT ,
667
+ baton -> indexList ) < 0 ) {
668
+ return njsBaton_setErrorDPI (baton );
669
+ }
670
+ return true;
671
+ }
672
+
673
+
674
+ //-----------------------------------------------------------------------------
675
+ // njsSodaCollection_listIndexesPostAsync()
676
+ // Defines the value returned to JS
677
+ //-----------------------------------------------------------------------------
678
+ static bool njsSodaCollection_listIndexesPostAsync (njsBaton * baton ,
679
+ napi_env env , napi_value * result )
680
+ {
681
+ napi_value temp ;
682
+ uint32_t i ;
683
+
684
+ NJS_CHECK_NAPI (env , napi_create_array_with_length (env ,
685
+ baton -> indexList -> numStrings , result ))
686
+ for (i = 0 ; i < baton -> indexList -> numStrings ; i ++ ) {
687
+ NJS_CHECK_NAPI (env , napi_create_string_utf8 (env ,
688
+ baton -> indexList -> strings [i ],
689
+ baton -> indexList -> stringLengths [i ], & temp ))
690
+ NJS_CHECK_NAPI (env , napi_set_element (env , * result , i , temp ))
691
+ }
692
+
693
+ return true;
694
+ }
695
+
696
+
697
+
698
+
636
699
//-----------------------------------------------------------------------------
637
700
// njsSodaCollection_newFromBaton()
638
701
// Called when a SODA collection is being created from the baton.
0 commit comments