Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

[master < E-util-docs] Write docs for util module #1012

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions mage/query-modules/cpp/util_module.md
Original file line number Diff line number Diff line change
@@ -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}) => (
<span
style={{
backgroundColor: color,
borderRadius: '2px',
color: '#fff',
padding: '0.2rem',
}}>
{children}
</span>
);

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** | <Highlight color="#FB6E00">**algorithm**</Highlight> |
| **Implementation** | <Highlight color="#FB6E00">**C++**</Highlight> |
| **Graph direction** | <Highlight color="#FB6E00">**directed**</Highlight>/<Highlight color="#FB6E00">**undirected**</Highlight> |
| **Edge weights** | <Highlight color="#FB6E00">**weighted**</Highlight>/<Highlight color="#FB6E00">**unweighted**</Highlight> |
| **Parallelism** | <Highlight color="#FB6E00">**sequential**</Highlight> |

### 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:
vpavicic marked this conversation as resolved.
Show resolved Hide resolved

- `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 |
+-----------------------------------+
```
1 change: 1 addition & 0 deletions mage/templates/_mage_spells.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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). |


Expand Down
1 change: 1 addition & 0 deletions sidebars/sidebarsMAGE.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading