Skip to content

Commit

Permalink
Improve documentation for getStatus (#392)
Browse files Browse the repository at this point in the history
* Improve documentation for getStatus

Co-authored-by: mix irving <[email protected]>
  • Loading branch information
arj03 and mixmix authored May 18, 2023
1 parent 518aded commit c1e9479
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,30 @@ also be read using `ssb.db.onMsgAdded.value`.

### getStatus

Gets the current db status, same functionality as
[db.status](https://github.com/ssbc/ssb-db#dbstatus) in ssb-db.
Gets the current db status, either as a synchronous function or
observeable. This is similar to
[db.status](https://github.com/ssbc/ssb-db#dbstatus) in ssb-db. The
value contains the following information:

- `log`: current byte offset of the head of the log in bytes (the log
is the primary source of truth where raw messages are stored)
- `jit`: an object with the offset of each [jitdb] index
- `indexes`: an object with the offset of each level index
- `progress`: a float representing the index completion from 0 to 1

Example:

```js
// synchronous
const status = ssb.db2.getStatus()

// observeable
const listener = (status) => console.log(status.progress)
const unsubscribe = ssb.db2.getStatus(listener)

// later
unsubscribe() // unsubscribes the listener from status updates
```

### reindexEncrypted(cb)

Expand Down

0 comments on commit c1e9479

Please sign in to comment.