This function retrieves an entry from the local chain or the DHT. If options.StatusMask
is present, it determines which entries to return, depending on their status. If options.GetMask
is present, this option allows you to specify what information about the entry you want. For more on that, see Entry Objects and Masks.
If options.Local
is set to true, it indicates that the get refers to the local chain only. This allows you to retrieve specific entries from your chain, which includes private entries that aren't published to the DHT.
If options.Bundle
is set to true, it indicates that the get refers to the currently started bundle only. If no bundle has been started, returns an error.
If only StatusMask
value specified or only Entry
is specified the return value will be the actual entry value. Otherwise the return value will be an object with properties of the same name as the mask name.
hash: hash-string
options: object (optional)
options.StatusMask: Status-int
options.GetMask: Mask-int
options.Local: boolean
options.Bundle: boolean
Returns: Entry-object OR HC.HashNotFound
// Assume postHash is the hash of a previous post. In this example we do a simple get with no options: var r = get(postHash) debug(r) // "I can haz cheezburger?" // In this example we do a "get" with "GetMask" options: var r = get(postHash, { GetMask: HC.GetMask.Entry + HC.GetMask.EntryType }) debug(r) /* { "Entry":"I can haz cheezburger?", "EntryType":"meow" } */ // There is a scenario where no entry is found matching the hash, you should usually check it var r = get(postHash) if (r === HC.HashNotFound) { // handle hashNotFound case } else { // do something with the entry }