Module openvet_storage::database::functions

source ·
Expand description

§Database user-defined functions

This module handles registering user-defined functions into the SQLite database. This allows for enforcing type validity in the database, and ensuring there are no inconcistencies after performing a migration, and accessing type fields.

§Examples

Reading the documentation for the individual functions yields more information on this. But for example, in a database table which stores JSON-encoded values, these functions allow for type-checking this in the database upon insertion.

CREATE TABLE my_table(
    id INTEGER NOT NULL PRIMARY KEY,
    checksum TEXT NOT NULL UNIQUE CHECK(type_validate("openvet_common::rust::Checksum", checksum)),
    files TEXT NOT NULL CHECK(type_validate("openvet_common::tree::Node", files))
) STRICT;

Functions§

Type Aliases§

  • Signature for a validation function, used to validate JSON.