Skip to content

nut.data

Data Persistence Utility.

Handles saving, retrieving, and deleting persistent framework or schema data in the nutscript/ folder.

Functions

nut.data.set (key, value, global, ignoreMap)
nut.data.set

Set and save data in the nutscript folder.

Parameters:

string key The name of the data file

vararg value The value to save (must be encodable via pon)

boolean global optional. default: false If true, shared across all schemas

boolean ignoreMap optional. default: false If true, ignores map-specific folder

Returns:

string Full file path where the data was saved

nut.data.get (key, default, global, ignoreMap, refresh)
nut.data.get

Retrieves a saved value from the nutscript folder. Optionally returns cached value unless refreshed.

Parameters:

string key The data key

vararg default Value to return if key is not found

boolean global optional. default: false If true, shared across all schemas

boolean ignoreMap optional. default: false If true, ignores map-specific folder

boolean refresh optional. default: false If true, bypasses cache and reads file

Returns:

any The stored value

Or

default The fallback value if not found

nut.data.delete (key, global, ignoreMap)
nut.data.delete

Deletes a saved value. Removes both the file and its cache entry.

Parameters:

string key The data key

boolean global optional. default: false If true, shared across all schemas

boolean ignoreMap optional. default: false If true, ignores map-specific folder

Returns:

bool True if deleted, false if not found