get

Starts a request for data under a user account. It works like the Holster API's get(), except the key can also be an array that names whose account to read.

Parameter

Description

key

A string for a key on the logged in user's account, or an array of [publicKey, key] for a key on any account.

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.

A string key needs a logged in user, since it refers to their own account. With an array, the first value is the public key of the account to read, so nobody needs to be logged in.

Examples

// Data on the logged in user's account.
await user.get("profile").put({name: "Alice"})
const profile = await user.get("profile")

// With a callback.
user.get("profile", profile => console.log(profile.name))

// Data on another account, no login needed.
const theirs = await user.get([alicePublicKey, "profile"])

// Continue the chain into a nested key.
const name = await user.get([alicePublicKey, "profile"]).next("name")

// With a lex query.
const partial = await user.get([alicePublicKey, "profile"], {".": "name"})

// Listen for changes to another account's data.
user.get([alicePublicKey, "profile"]).on(console.log)

Only the account's owner can write to it, since every put() is signed with the logged in user's keys and verified before it's stored.