Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Returns the specified registry section in the following format: RegistrySection.{entry_key_name}.

Code Block
languagejs
Promise <RegistryObject> read()

Returns all registry sections in the following format: RegistryObject.{section_name}.{entry_key_name}.

write()
Code Block
languagejs
Promise <void> write(DOMString sectionName, DOMString key, DOMString value)

...

Writes the specified registry section to the registry. If the registry section does not exist, it will be created; otherwise, the entries will be added or updated in the existing registry section (preexisting registry entries that are not specified in the write operation will be unaffected). When there are multiple entries in a single registry section that need to be updated, this variant of the write() method method will perform better than the others.

Code Block
languagejs
Promise <void> write(RegistryObject)

Writes the specified registry sections/entries to the registry. Registry sections and entries that do not exist will be created, and existing entries will be updated (preexisting registry sections/entries that are not specified in the write operation will be unaffected). When there are multiple registry sections that need to be updated, this variant of the write() method method will perform better than the others.

Tip
titleTip

To delete a registry entry or section, assign it a null value.

...

Note
titleNote

The single-entry variant of the write() method will not perform well when used to write multiple entries successively. For optimal performance, use the single-section variant of write() method to write multiple entries to a single section and the full-registry variant method to write to multiple sections.

...

Code Block
languagejs
var registryClass = require("@brightsign/registry");
var registry = new registryClass();
 
//WritesReads the entire registry to the log.
registry.read().then(function(registry) {
    console.log(JSON.stringify(registry));
});
 
//WritesReads the contents of the "networking" registry to the log.
registry.read("networking").then(
	function(registry){console.log(JSON.stringify(registry));});
 
//Writes multiple entries to multiple sections.
registry.write({networking:{ssh:"22", http_server:"8080"}, autorun:{devicesetupcomplete:"1"}} ).then(
	function(){console.log("Write Successful");});
 
//Updates a single section.
registry.write("networking", {ssh:"22", http_server:"8080"}).then(
	function(){console.log("Write Successful");});
 
//Deletes a registry section and entry, and creates a new section.
registry.write({networking:{ssh:"22", http_server:null}, autorun:null, section1:{test:"val"}} ).then(
	function(){console.log("Write Successful");});