Skip to content
This repository was archived by the owner on Dec 6, 2018. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ with the outer db when saving or reading!

## Hooks

Hooks are specially built into Sublevel so that you can
Hooks are specially built into Sublevel so that you can
do all sorts of clever stuff, like generating views or
logs when records are inserted!

Expand All @@ -87,8 +87,8 @@ var sub = db.sublevel('SEQ')

db.pre(function (ch, add) {
add({
key: ''+Date.now(),
value: ch.key,
key: ''+Date.now(),
value: ch.key,
type: 'put',
// NOTE: pass the destination db to add the value to that subsection!
prefix: sub
Expand All @@ -111,11 +111,15 @@ instead of the current section, similar to the `pre` hook above.

``` js
var sub1 = db.sublevel('SUB_1')
var sub2 = db.sublevel('SUM_2')
var sub2 = db.sublevel('SUB_2')

sub.batch([
{key: 'key', value: 'Value', type: 'put'},
// Pass the sublevel instance
{key: 'key', value: 'Value', type: 'put', prefix: sub2},
// Or pass an array with the sublevel string. This is useful if you need
// to serialize the function call, as with multilevel/RPC
{key: 'key', value: 'Value', type: 'put', prefix: ['SUB_2']}
], function (err) {...})
```

Expand Down