File tree Expand file tree Collapse file tree 6 files changed +79
-7
lines changed
Expand file tree Collapse file tree 6 files changed +79
-7
lines changed Original file line number Diff line number Diff line change @@ -39,4 +39,4 @@ allprojects {
3939 maven { url ' https://www.jitpack.io' }
4040 }
4141}
42- apply from : " ../../android/build.gradle" apply from : " ../../android/build.gradle" apply from : " ../../android/build.gradle" apply from : " ../../android/build.gradle" apply from : " ../../android/build.gradle"
42+ apply from : " ../../android/build.gradle" apply from : " ../../android/build.gradle" apply from : " ../../android/build.gradle" apply from : " ../../android/build.gradle" apply from : " ../../android/build.gradle" apply from : " ../../android/build.gradle " apply from : " ../../android/build.gradle " apply from : " ../../android/build.gradle " apply from : " ../../android/build.gradle " apply from : " ../../android/build.gradle " apply from : " ../../android/build.gradle "
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { Collection } from 'cbl-reactnative' ;
3+ import CBLCollectionActionContainer from '@/components/CBLCollectionActionContainer' ;
4+ import listIndexes from '@/service/indexes/list' ;
5+
6+ export default function IndexesListScreen ( ) {
7+ function reset ( ) { }
8+
9+ async function update ( collection : Collection ) : Promise < string [ ] > {
10+ try {
11+ const indexes = await listIndexes ( collection ) ;
12+ if ( indexes . length > 0 ) {
13+ return indexes ;
14+ } else {
15+ return [ 'No indexes found.' ] ;
16+ }
17+ } catch ( error ) {
18+ // @ts -ignore
19+ return [ error . message ] ;
20+ }
21+ }
22+
23+ return (
24+ < CBLCollectionActionContainer
25+ handleUpdatePressed = { update }
26+ handleResetPressed = { reset }
27+ screenTitle = "List Indexes"
28+ />
29+ ) ;
30+ }
Original file line number Diff line number Diff line change 5656 <string >$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route </string >
5757 <string >$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route </string >
5858 <string >$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route </string >
59+ <string >$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route </string >
60+ <string >$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route </string >
61+ <string >$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route </string >
62+ <string >$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route </string >
63+ <string >$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route </string >
64+ <string >$(PRODUCT_BUNDLE_IDENTIFIER).expo.index_route </string >
5965 </array >
6066 <key >UILaunchStoryboardName </key >
6167 <string >SplashScreen </string >
Original file line number Diff line number Diff line change 1+ import { Collection } from 'cbl-reactnative' ;
2+
3+ export default async function listIndexes (
4+ collection : Collection
5+ ) : Promise < string [ ] > {
6+ return await collection . indexes ( ) ;
7+ }
Original file line number Diff line number Diff line change @@ -176,12 +176,13 @@ public class DataAdapter {
176176 public func adaptIndexToArrayAny( dict: NSDictionary , reject: @escaping RCTPromiseRejectBlock ) -> ( Bool , IndexArgs ) {
177177 let indexArgs = IndexArgs ( )
178178 var isError = false
179- var result = [ [ Any] ] ( )
180179 indexArgs. indexType = String ( dict [ " type " ] as! NSString )
181- for (key, value) in dict [ " items " ] as! NSDictionary {
182- result. append ( [ key, value] )
180+ let items = dict [ " items " ] as! NSArray
181+ for item in items {
182+ if let array = item as? [ Any ] {
183+ indexArgs. indexes. append ( array)
184+ }
183185 }
184- indexArgs. indexes = result
185186 if ( indexArgs. indexes. isEmpty || indexArgs. indexType. isEmpty) {
186187 isError = true
187188 reject ( " INDEX_ERROR " , " Can't parse Index information " , nil )
Original file line number Diff line number Diff line change @@ -109,7 +109,22 @@ export class CblReactNativeEngine implements ICoreEngine {
109109 }
110110
111111 collection_CreateIndex ( args : CollectionCreateIndexArgs ) : Promise < void > {
112- return Promise . resolve ( undefined ) ;
112+ return new Promise ( ( resolve , reject ) => {
113+ this . CblReactNative . collection_CreateIndex (
114+ args . indexName ,
115+ args . index ,
116+ args . collectionName ,
117+ args . scopeName ,
118+ args . name
119+ ) . then (
120+ ( ) => {
121+ resolve ( ) ;
122+ } ,
123+ ( error : any ) => {
124+ reject ( error ) ;
125+ }
126+ ) ;
127+ } ) ;
113128 }
114129
115130 collection_DeleteCollection ( args : CollectionArgs ) : Promise < void > {
@@ -282,7 +297,20 @@ export class CblReactNativeEngine implements ICoreEngine {
282297 }
283298
284299 collection_GetIndexes ( args : CollectionArgs ) : Promise < { indexes : string [ ] } > {
285- return Promise . resolve ( { indexes : [ ] } ) ;
300+ return new Promise ( ( resolve , reject ) => {
301+ this . CblReactNative . collection_GetIndexes (
302+ args . name ,
303+ args . scopeName ,
304+ args . collectionName
305+ ) . then (
306+ ( items : { indexes : string [ ] } ) => {
307+ resolve ( items ) ;
308+ } ,
309+ ( error : any ) => {
310+ reject ( error ) ;
311+ }
312+ ) ;
313+ } ) ;
286314 }
287315
288316 collection_PurgeDocument ( args : CollectionPurgeDocumentArgs ) : Promise < void > {
You can’t perform that action at this time.
0 commit comments