@@ -44,6 +44,7 @@ NJS_NAPI_METHOD_DECL_ASYNC(njsSodaCollection_insertMany);
4444NJS_NAPI_METHOD_DECL_ASYNC (njsSodaCollection_insertManyAndGet );
4545NJS_NAPI_METHOD_DECL_ASYNC (njsSodaCollection_insertOne );
4646NJS_NAPI_METHOD_DECL_ASYNC (njsSodaCollection_insertOneAndGet );
47+ NJS_NAPI_METHOD_DECL_ASYNC (njsSodaCollection_listIndexes );
4748NJS_NAPI_METHOD_DECL_ASYNC (njsSodaCollection_save );
4849NJS_NAPI_METHOD_DECL_ASYNC (njsSodaCollection_saveAndGet );
4950NJS_NAPI_METHOD_DECL_ASYNC (njsSodaCollection_truncate );
@@ -57,6 +58,7 @@ static NJS_ASYNC_METHOD(njsSodaCollection_insertManyAsync);
5758static NJS_ASYNC_METHOD (njsSodaCollection_insertManyAndGetAsync );
5859static NJS_ASYNC_METHOD (njsSodaCollection_insertOneAsync );
5960static NJS_ASYNC_METHOD (njsSodaCollection_insertOneAndGetAsync );
61+ static NJS_ASYNC_METHOD (njsSodaCollection_listIndexesAsync );
6062static NJS_ASYNC_METHOD (njsSodaCollection_saveAsync );
6163static NJS_ASYNC_METHOD (njsSodaCollection_saveAndGetAsync );
6264static NJS_ASYNC_METHOD (njsSodaCollection_truncateAsync );
@@ -67,6 +69,7 @@ static NJS_ASYNC_POST_METHOD(njsSodaCollection_dropIndexPostAsync);
6769static NJS_ASYNC_POST_METHOD (njsSodaCollection_getDataGuidePostAsync );
6870static NJS_ASYNC_POST_METHOD (njsSodaCollection_insertManyAndGetPostAsync );
6971static NJS_ASYNC_POST_METHOD (njsSodaCollection_insertOneAndGetPostAsync );
72+ static NJS_ASYNC_POST_METHOD (njsSodaCollection_listIndexesPostAsync );
7073static NJS_ASYNC_POST_METHOD (njsSodaCollection_saveAndGetPostAsync );
7174
7275// processing arguments methods
@@ -99,6 +102,8 @@ static const napi_property_descriptor njsClassProperties[] = {
99102 napi_default , NULL },
100103 { "getName" , NULL , njsSodaCollection_getName , NULL , NULL , NULL ,
101104 napi_default , NULL },
105+ { "listIndexes" , NULL , njsSodaCollection_listIndexes , NULL , NULL , NULL ,
106+ napi_default , NULL },
102107 { "save" , NULL , njsSodaCollection_save , NULL , NULL , NULL , napi_default ,
103108 NULL },
104109 { "saveAndGet" , NULL , njsSodaCollection_saveAndGet , NULL , NULL , NULL ,
@@ -633,6 +638,64 @@ static bool njsSodaCollection_insertOneAndGetPostAsync(njsBaton *baton,
633638}
634639
635640
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+
636699//-----------------------------------------------------------------------------
637700// njsSodaCollection_newFromBaton()
638701// Called when a SODA collection is being created from the baton.
0 commit comments