put

Writes one or more nodes, which are stored and sent to the relay.

Parameter

Description

graph

The data to write, in graph format. Can contain any number of nodes.

callback

Optional function that receives null on success, or an error message.

Every property you write needs a state in its node's ">" metadata. When two writes change the same property, the one with the higher state wins, so use the current time (Date.now()) as the Holster API does.

Examples

const now = Date.now()

holster.wire.put(
  {
    root: {
      _: {"#": "root", ">": {key: now}},
      key: "value",
    },
  },
  err => {
    if (err) console.error(err)
  },
)

Writing two nodes, where one refers to the other:

const now = Date.now()

holster.wire.put(
  {
    root: {
      _: {"#": "root", ">": {profile: now}},
      profile: {"#": "profile-node"},
    },
    "profile-node": {
      _: {"#": "profile-node", ">": {name: now}},
      name: "Alice",
    },
  },
  err => {
    if (err) console.error(err)
  },
)

This is what the Holster API writes for holster.get("profile").put({name: "Alice"}), except it generates a random id for the new node.