put
Writes one or more nodes, which are stored and sent to the relay.
Parameter | Description |
|---|---|
| The data to write, in graph format. Can contain any number of nodes. |
| Optional function that receives |
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.