Skip to content

Commit d96720e

Browse files
committed
docs(readme): Split the documentation for getIndex
Fixes #131
1 parent 9951c6d commit d96720e

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

README.md

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -178,22 +178,6 @@ db.push("/arraytest/myarray[]", {
178178
// This will set the next index as an object {myTest: 'test'}
179179
db.push("/arraytest/myarray[]/myTest", 'test', true);
180180

181-
182-
// You can have the number of element
183-
let numberOfElement = db.count("/arraytest/myarray");
184-
185-
186-
// You can have the current index of an object
187-
db.push("/arraytest/myarray", {id: 65464646155, name: "test"}, true);
188-
db.getIndex("/arraytest/myarray", 65464646155);
189-
// By default, the property is 'id'
190-
// You can add another property instead
191-
db.getIndex("/arraytest/myarray", "test", "name");
192-
193-
194-
// It's useful if you want to delete some object
195-
db.delete("/arraytest/myarray[" + db.getIndex("/arraytest/myarray", 65464646155) + "]");
196-
197181
```
198182

199183
#### Last Item in Array
@@ -213,6 +197,28 @@ db.delete("/arraytest/lastItemArray[-1]");
213197
// This will return 2 since 3 just got removed
214198
db.getData("/arraytest/lastItemArray[-1]");
215199
```
200+
#### Count for Array
201+
```javascript
202+
//
203+
db.push("/arraytest/list", [{id: 65464646155, name: "test"}], true);
204+
205+
// You can have the number of element, in this case = 1
206+
let numberOfElement = db.count("/arraytest/list");
207+
```
208+
209+
#### Get Index in Array
210+
```javascript
211+
212+
// You can have the current index of an object
213+
db.push("/arraytest/myarray", {id: 65464646155, name: "test"}, true);
214+
db.getIndex("/arraytest/myarray", 65464646155);
215+
// By default, the property is 'id'
216+
// You can add another property instead
217+
db.getIndex("/arraytest/myarray", "test", "name");
218+
219+
// It's useful if you want to delete some object
220+
db.delete("/arraytest/myarray[" + db.getIndex("/arraytest/myarray", 65464646155) + "]");
221+
```
216222
### Exception/Error
217223
#### Type
218224

0 commit comments

Comments
 (0)