get

Starts a request for a top level key. Every request begins with get().

Parameter

Description

key

The 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. 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.

The data is returned as it was written: a string, number, true, false, null or an object, with any nested objects included. A key that doesn't exist returns null, and errors are logged to the console rather than returned.

Examples

// With await.
const value = await holster.get("key")

// With a callback.
holster.get("key", console.log)

// Continue the chain into a nested key.
const property = await holster.get("item").next("property")

// Only return data that's already in memory.
holster.get("key", console.log, {fast: true})

A lex query returns an object with only the matching properties:

// With await.
const item = await holster.get("item", {".": "property"})
console.log(item.property)

// With a callback.
holster.get("item", {".": "property"}, item => console.log(item.property))

A lex query ends the chain. Without one, and without a callback or await, get() returns the chain so it can continue with next(), put(), on() or off().

To read data stored under a user account, use user.get().