Node-RED
docsapistorage

Storage API

The Storage API provides a pluggable way to configure where the Node-RED runtime stores data.

The information stored by the API includes:

  • flow configuration
  • flow credentials
  • user settings
  • user sessions
  • node library content

By default, Node-RED uses a local file-system implementation of this API.

The API functions are documented here.

Configuration

The storageModule property in settings.js can be used to identify a custom module to use:

storageModule: require("my-node-red-storage-plugin")

Promises

The API makes extensive use of JavaScript promises.

A promise represents the eventual result of an asynchronous operation. It acts as a placeholder until the result is available.

Node-RED uses the When.js library. The following example shows it in use. For a more complete example, the default file-system implementation is located in red/runtime/storage/localfilesystem.js.

function getFlows() {
 // create and return a promise
 return when.promise(function(resolve,reject) {
 // resolve - a function to be called with the successful result
 // reject - a function to be called if an error occurs
 // do some asynchronous work, with a callback on completion
 doAsyncWork(function(err,result) {
 if (err) {
 reject(err);
 } else {
 resolve(result);
 }
 });
 });
}
getFlows()
 .then(function(result) {
 // Called when getFlows completes successfully
 })
 .otherwise(function(err) {
 // Called when getFlows hits an error
 });

Node-RED: Low-code programming for event-driven applications.

Copyright OpenJS Foundation and Node-RED contributors. All rights reserved. The OpenJS Foundation has registered trademarks and uses trademarks. For a list of trademarks of the OpenJS Foundation, please see our Trademark Policy and Trademark List. Trademarks and logos not indicated on the list of OpenJS Foundation trademarks are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.

The OpenJS Foundation | Terms of Use | Privacy Policy | OpenJS Foundation Bylaws | Trademark Policy | Trademark List | Cookie Policy

AltStyle によって変換されたページ (->オリジナル) /