Skip to content

Data Nodes ​

A data node is the micro app's persistent data storage mechanism. Data is isolated and stored based on the account and app ID. Each micro app can have multiple data nodes, and each data node can store multiple key objects. Nodes must be registered in the config file to be used properly.

Basic Concepts ​

  • APP level: Used globally by all users, suitable for public config
  • USER level: Exclusive to the currently logged-in account, data isolated between accounts

Public Mode ​

Data nodes support setting the isPublic property:

  • isPublic: true - Readable in public mode
  • isPublic: false - Readable and writable only by logged-in users

Permission Description ​

Data permissions can be divided into three types (read, write, (passthrough) use). Data nodes at all levels support template replacement usage in the API's request passthrough request. This ensures sensitive data is not leaked to the frontend while still safely using the sensitive data in the data node to ensure normal passthrough API calls. Please refer to the following for read/write permissions:

Login Mode / ScopeAPP (Public)APPUSER (Public)USER
Public ModeRead-Read-
Normal AccountRead-Read, WriteRead, Write
Admin AccountRead, WriteRead, WriteRead, WriteRead, Write

Config Description ​

Configure data nodes in app.config.js:

javascript
export default {
  // ... other config code omitted here

  // Need to declare dataNode permission
  permissions: ['dataNode'],

  dataNodes: {
    // City list - APP level, publicly readable
    cityList: {
      scope: 'app',
      isPublic: true
    },
    // User selected city - USER level, publicly readable
    userCity: {
      scope: 'user',
      isPublic: true
    },
    // API key - APP level, only admin writable
    apiKey: {
      scope: 'app',
      isPublic: false
    },
    // User private data - USER level
    privateData: {
      scope: 'user',
      isPublic: false
    }
  }
};

Config Parameters ​

ParameterTypeDescription
scopestringData scope: 'app' or 'user'
isPublicbooleanWhether readable in public mode

Usage Scenario Example ​

Using a weather micro app as an example:

DataScopePublicDescription
City listAPP✅All users see the same data
User selected cityUSER✅Each user selects independently
API keyAPP❌Only admin config
User custom settingsUSER❌Each user configures independently

TIP

If you cannot determine the data scope, fully use USER-level data nodes.

Usage Method ​

For detailed API calls, please refer to Platform API - Data Nodes.

Released under the MIT License.