File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -173,17 +173,18 @@ export class JsonDB {
173173
174174 /**
175175 * Returns the index of the object that meets the criteria submitted.
176- * @param dataPath
177- * @param id the value of the index
176+ * @param dataPath base dataPath from where to start searching
177+ * @param searchValue value to look for in the dataPath
178+ * @param propertyName name of the property to look for searchValue
178179 */
179- public getIndex ( dataPath : string , value : ( string | number ) , item :string = 'id' ) : number {
180+ public getIndex ( dataPath : string , searchValue : ( string | number ) , propertyName :string = 'id' ) : number {
180181 const result = this . getData ( dataPath ) ;
181182 if ( ! Array . isArray ( result ) ) {
182183 throw new DataError ( `DataPath: ${ dataPath } is not an array.` , 11 )
183184 }
184185 const path = this . processDataPath ( dataPath ) ;
185186 const data = this . retrieveData ( path , false ) ;
186- return data . map ( function ( element :any ) { return element [ item ] ; } ) . indexOf ( value ) ;
187+ return data . map ( function ( element :any ) { return element [ propertyName ] ; } ) . indexOf ( searchValue ) ;
187188 }
188189
189190 /**
You can’t perform that action at this time.
0 commit comments