next

Moves a request into a nested key. It takes the same parameters as get(), must be called after it, and can be repeated to go as deep as needed.

Parameter

Description

key

The nested key to request, a string.

lex

Optional lex query to return only some of the node's properties.

callback

Optional function that receives the data, ending the chain. Leave it out to await the result, or to chain more functions.

options

Optional object, passed after the callback. {fast: true} only returns data already in memory, see on.

A key that doesn't exist returns null.

Examples

// With await.
const name = await holster.get("item").next("child").next("name")

// With a callback.
holster.get("item").next("child", console.log)

// With a lex query.
const child = await holster.get("item").next("child", {".": "name"})
console.log(child.name)

// With a lex query and a callback.
holster
  .get("item")
  .next("child", {".": "name"}, child => console.log(child.name))

// Write to a nested key.
await holster.get("item").next("child").next("name").put("nested")

// Listen to a nested node.
holster.get("item").next("child").on(console.log)