diff --git a/mage/query-modules/cpp/util_module.md b/mage/query-modules/cpp/util_module.md new file mode 100644 index 00000000000..a99bbd17675 --- /dev/null +++ b/mage/query-modules/cpp/util_module.md @@ -0,0 +1,67 @@ +--- +id: util_module +title: util_module +sidebar_label: util_module +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import RunOnSubgraph from '../../templates/_run_on_subgraph.mdx'; + +export const Highlight = ({children, color}) => ( + +{children} + +); + +The util module offers a range of functions for tasks such as validation and creating cryptographic hash values. This module serves as a practical resource for streamlining a variety of tasks related to database operations. + +[![docs-source](https://img.shields.io/badge/source-util_module-FB6E00?logo=github&style=for-the-badge)](https://github.com/memgraph/mage/tree/main/cpp/util_module) + +| Trait | Value | +| ------------------- | ----------------------------------------------------- | +| **Module type** | **algorithm** | +| **Implementation** | **C++** | +| **Graph direction** | **directed**/**undirected** | +| **Edge weights** | **weighted**/**unweighted** | +| **Parallelism** | **sequential** | + +### Procedures + + +### `md5(values)` + +Gets the string representation of every element in the input list, concatenates it into a single string, and returns the md5 hash of that string. +NOTE: The format of string representations can be seen by checking ToString in [CPP API](/memgraph/reference-guide/query-modules/api/cpp-api) documentation for desired type or Value. + +#### Input: + +- `values: List[Any]` ➡ input list containing elements which can be any of Memgraph's data types. + +#### Output: + +- `result: string` ➡ resulting md5 hash returned as string. + +#### Usage: + +NOTE: The hash provided in this documentation will be different from the user's hash for the same input unless the node has the same ID because `Node.ToString()` uses the node's ID in string formation, so different IDs equal different strings, hence, different hashes. + +```cypher +CREATE (d:Dog); +MATCH (d:Dog) +CALL util_module.md5([d, "string", 50]) YIELD result RETURN result; +``` + +```plaintext ++-----------------------------------+ +| result | ++-----------------------------------+ +| 47e656a5f446fc21316e97df90e8ae33 | ++-----------------------------------+ +``` diff --git a/mage/templates/_mage_spells.mdx b/mage/templates/_mage_spells.mdx index 83634d4a33b..1dc423a90d2 100644 --- a/mage/templates/_mage_spells.mdx +++ b/mage/templates/_mage_spells.mdx @@ -61,6 +61,7 @@ | [migrate](/mage/query-modules/python/migrate) | Python | A module that can access data from a MySQL, SQL Server or Oracle database. | | [periodic](/mage/query-modules/cpp/periodic) | C++ | A module containing procedures for periodically running difficult and/or memory/time consuming queries. | | rust_example | Rust | Example of a basic module with input parameters forwarding, made in Rust. | +| [util_module](/mage/query-modules/cpp/util_module) | C++ | A module which offers a range of functions for tasks such as validation and creating cryptographic hash values. This module serves as a practical resource for streamlining a variety of tasks related to database operations. | | [uuid_generator](/mage/query-modules/cpp/uuid-generator) | C++ | A module that generates a new universally unique identifier (UUID). | diff --git a/sidebars/sidebarsMAGE.js b/sidebars/sidebarsMAGE.js index 3d940c7c061..957190613f2 100644 --- a/sidebars/sidebarsMAGE.js +++ b/sidebars/sidebarsMAGE.js @@ -64,6 +64,7 @@ module.exports = { "query-modules/python/temporal-graph-networks", "query-modules/python/tsp", "query-modules/python/union-find", + "query-modules/cpp/util_module", "query-modules/cpp/uuid-generator", "query-modules/python/vrp", "query-modules/cpp/weakly-connected-components"