Clarify eventlog and feed iterator options, and usage in tests

The `gt`/`gte`/`lt`/`lte` options for enventlog and feed iterators
take the hash of an item, and that wasn't clear from the API docs.
Also added more info to the `limit` option.

To see usage examples, many people are likely to turn to test suite.
In the tests for eventlog and feed, the `items` variable first
referred to an iterator with the actual items, and then later in
the tests `items` was an array of the item hashes. This switch of
types can be pretty confusing, thus the variable names were disambiguated.
This commit is contained in:
Gergely Imreh
2018-04-14 10:16:00 +01:00
parent 5a97d4886c
commit f6688ffe8d
3 changed files with 114 additions and 110 deletions

24
API.md
View File

@@ -188,18 +188,20 @@ const db = await orbitdb.eventlog(anotherlogdb.address)
**options** : It is an object which supports the following properties
`gt - (string)` Greater than
`gt - (string)` Greater than, takes an item's `hash`.
`gte - (string)` Greater than or equal to
`gte - (string)` Greater than or equal to, takes an item's `hash`.
`lt - (string)` Less than
`lt - (string)` Less than, takes an item's `hash`.
`lte - (string)` Less than or equal to
`lte - (string)` Less than or equal to, takes an item's `hash` value.
`limit - (integer)` Limiting the entries of result
`limit - (integer)` Limiting the entries of result, defaults to `1`, and `-1` means all items (no limit).
`reverse - (boolean)` If set to true will result in reversing the result.
If `hash` not found when passing `gt`, `gte`, `lt`, or `lte`, the iterator will return all items (respecting `limit` and `reverse`).
```javascript
const all = db.iterator({ limit: -1 })
.collect()
@@ -240,18 +242,20 @@ See the [Store](#store) section for details of common methods and properties.
**options** : It is an object which supports the following properties
`gt - (string)` Greater than
`gt - (string)` Greater than, takes an item's `hash`.
`gte - (string)` Greater than or equal to
`gte - (string)` Greater than or equal to, takes an item's `hash`.
`lt - (string)` Less than
`lt - (string)` Less than, takes an item's `hash`.
`lte - (string)` Less than or equal to
`lte - (string)` Less than or equal to, takes an item's `hash`.
`limit - (integer)` Limiting the entries of result
`limit - (integer)` Limiting the entries of result, defaults to `1`, and `-1` means all items (no limit).
`reverse - (boolean)` If set to true will result in reversing the result.
If `hash` not found when passing `gt`, `gte`, `lt`, or `lte`, the iterator will return all items (respecting `limit` and `reverse`).
```javascript
const all = db.iterator({ limit: -1 })
.collect()