history_enabled

Determines if commit history is enabled for the current scope or a specified target scope.

  • Without arguments: Checks whether commit history is enabled for the current scope. This is allowed in a collection scope or the @thingsdb scope, but cannot be used in a @node scope as commit history cannot be enabled for a node scope.
  • With one argument (scope): Allowed only in the @thingsdb scope. Checks whether commit history is enabled for the given scope.

Checking if commit history is enabled requires at least QUERY privileges for the target scope (viewing the actual history via history() requires CHANGE privileges as well).

This function does not generate a change.

Function

history_enabled([scope])

Arguments

Argument Type Description
scope str (optional) Target scope name (e.g. '//stuff', '@collection:stuff', or '/thingsdb'). Only allowed when called in the @thingsdb scope.

Return value

Returns true if commit history is enabled for the scope and otherwise false.

Example

This code shows an example use case of history_enabled() in the current scope:

history_enabled();

Return value in JSON format

false

This code shows an example use case of history_enabled() in the @thingsdb scope:

// Enable commit history on the //stuff collection
set_history('//stuff', true);

[
    history_enabled('//stuff'),
    history_enabled('/thingsdb'),
];

Return value in JSON format

[
    true,
    false
]