API
Datalogue
Datalogue is the entry point to the API, it is an autoload singleton.
At runtime you can use:
databases() -> Dictionary[string][DlDatabase]to retrieve all the databases as map using the id as keyget_database(id: String) -> DlDatabaseto retrieve the database with the given id or null if it does not exist
In tool mode you can use:
validate_id(id: String) -> Stringto check if the given string can be used for as a database id, if it can, the returned string is empty, otherwise it contains an error messageupdate_database(modified_db: DlDatabase, old_id: String = "") -> voidto save to disk a modification made to the given database, if you change the database id the old id should also given.copy_database(origin: DlDatabase, new_id: String) -> voidto create a copy on disk of the given database with the given iddelete_database(id: String) -> voidto remove a database from disk
In tool mode you can also connect to the following signals:
database_added()emitted when a database is inserted into the listdatabase_updated(db: DlDatabase)emitted when a database has been modified in the listdatabase_removed()emitted when a database is removed from the list
DlDatabase
DlDatabase represents 1 database designed by its id and containing items.
At runtime you can use:
id() -> Stringto retrieve the database’s idcount() -> intto retrieve the number of items in the databasestatistics() -> Dictionaryto retrieve some statistics about this database (more details below)items() -> Dictionaryto retrieve all the items in the form[<item id>: <item>]item_exists(id: String) -> boolto check if an item is in the databaseget_item(id: String) -> DlItemto retrieve the item with the given id or null if it does not exist
In tool mode you can use:
set_id(new_id: String) -> voidto change the database’s idduplicate(new_id: String = "") -> DlDatabaseto create a copy of this database with the givennew_id. Ifnew_idis empty then the copy has the same id as this database. Note: the copy is not written to disk, contrary to theDatalogue.copy_database functionvalidate_item_id(id: String) -> Stringto check if the given string can be used for as an item id, if it can, the returned string is empty, otherwise it contains an error messageadd_item(item: DlItem) -> voidto add the given item to the database. Note: the change is not written to disk until you callDatalogue.update_databasecopy_item(origin: DlItem, new_id: String) -> voidto create a copy of the given item with the givennew_id. Note: the change is not written to disk until you callDatalogue.update_databaseupdate_item(modified_item: DlItem, old_id: String = "") -> voidto update the givenmodified_item. If you have changed the item id, theold_idshould be also given. Note: the change is not written to disk until you callDatalogue.update_databaseremove_item(id: String) -> voidto remove the item with the given id from the database. Note: the change is not written to disk until you callDatalogue.update_database
In tool mode you can also connect to the following signals:
changed()emitted when the database has changed
The statistics are given as a Dictionary with the following structure:
["items"]contains the total number of item in the database["classes"]["<classif id>"]contains the number of items with the given classification["classes_values"]["<classif id>"]["<value>"]contains the number of items with the given classification value["values"]["<value id>"]contains the number of items with the given value["values_min"]["<value id>"]contains the minimum of the given value["values_max"]["<value id>"]contains the maximum of the given value["texts"]["<text id>"]contains the number of items with the given text