Register a new module for ThingsDB.
After a module is registered, a future() is required to use the new module.
Modules might need configuration; use set_module_conf(..) to apply the configuration.
Prior to ThingsDB v1.13.0, new_module(..) accepted an optional configuration parameter. A separate call to set_module_conf(..) is now required to apply the configuration.
ThingsDB has special support for Python modules, which is activated when your module file ends with .py. In this case, the Python interpreter will be used to start the module.
By default, a module can be used in all scopes. However, it is possible to restrict usage with set_module_scope(..).
This function generates a change.
new_module(name, source)
| Argument | Type | Description |
|---|---|---|
name |
str (required) | Name of the new module. |
source |
str (required) | Source of the module. This may be a filename or a GitHub repository (see sources). |
| Source | Description |
|---|---|
| Filename | The same file may be configured multiple times. The file must be a path relative to the modules path. If the file ends with .py, the Python interpreter will be used to start the module. |
| GitHub | A GitHub repository like github.com/owner/repo[:token][@tag/branch], for example: github.com/thingsdb/module-py-demo@v0.1.0. If no tag or branch is given, the default branch will be used. A personal access token may be used for private repositories. |
Returns nil. You might want to use module_info(..) to check if the module is running successfully.
Create a new module
demo:
new_module('demo', 'github.com/thingsdb/module-py-demo');
Return value in JSON format
null