nse

This function promises ThingsDB that your code has no-side-effects and therefore does not require a change.

Suppose you use the following code:

response = {};
response.text = "Some message";  // This enforces a change
response;  // Return the response

On the second code line, ThingsDB doesn’t know if response is a stored object or not. Therefore ThingsDB will create a change. Although the code example above is very simple and in this case can be simply re-written to avoid a change, it is not always that simple.

Function nse() could be used to promise ThingsDB that your code does not require a change.

nse();  // Promise we don'n need a change
response = {};
response.text = "Some message";
response;  // Return the response

This function raises an Operation error if there are side-effects which can’t be avoided. For example when used too late: x.y = 1; nse() or when a function really does require a change like nse(); new_type('T');.

This function does not generate a change.

Function

nse([statement])

Arguments

Argument Type Description
statement any (optional) Statement or block to wrap.

Return value

Return value of the given statement or nil.

Example

This code shows an example usage for nse():

// We don't make a change to the collection
nse();

response = {};
response.text = "Some message";  // This tells ThingsDB to create a change
response.changeId = change_id();  // This should be nil
response;  // Return the response

Return value in JSON format

{
    "text": "Some message",
    "changeId": null
}