Usage

Device SupportGroup Support
Info

Current storage capacity sdk abstracts the following capabilities:

  • key prefix: Automatically prefixes storage keys with dev id values to prevent data conflicts caused by storage on different devices of the same product.
  • Data Auto-Synchronization: When developers manipulate custom data, it is automatically stored both locally (using getStorage/setStorage) and in the cloud (using getDevProperty/saveDevProperty), ensuring synchronization between the two. The system always returns the latest data, preventing data loss in weak network environments by ensuring local operations are synchronized with the cloud.

SmartStorageAbility(options?: DeviceId | object)

Requires:
@ray-js/panel-sdk≥1.0.0

Description

Smart storage capability that provides cloud-persistent, device-level key-value storage

Parameters

ParameterTypeRequiredDescription
NoStorage capability initialization configuration

Return Value

Type: SmartStorageAbility
SmartStorageAbility instance

Referenced Types

typeDeviceId
export type DeviceId = string;

Valid Values

options.storageType
ValueDescriptionSince
local--
cloud--
both--

Methods

MethodDescription
initInitialize the storage capability and establish cloud and local storage channels
getRead the stored data for the specified key
getAllRead all stored data under the current device/group
setStore data for the specified key
setAllBatch store multiple key-value pairs
removeDelete the stored data for the specified key

Examples

Example

import { SmartDeviceModel, SmartStorageAbility } from '@ray-js/panel-sdk';

const sdm = new SmartDeviceModel({ abilities: [new SmartStorageAbility()] });