This tutorial will guide you through the process of creating human-readable IDs for databases and data views. These IDs are unique IDs and have a specified length, e.g., crnZQNey or 103diVbi.
To implement this solution, you need a BRYTER Connect license.
In this example, we assume that you want to write records to a database called General DB (in practice you will use your own database here). We will equip these records with human readable IDs.
-
Create a Custom action node
You can use the code below to create a Custom action designed to create IDs with a specified length. If you require more detailed instructions on creating a Custom action, visit the developer website. If you need further assistance, feel free to reach out to our technical success team at support@bryter.io.
-
Add a Custom action to your module
Create the Custom action that will generate the unique IDs. In the input field, define the desired length of the ID.
-
Reference the Custom action in the Write to a Database action
In the Write to a Database action writing to General DB where you create the record, reference the ID generated by the Custom action in the Request ID field. Fill the other fields as desired.
MetaData
{ "key": "request-id-create", "name": "request-id-create", "description": "create request id for dataviews", "developerEmail": "gundogdu@bryter.io", "entryPoint": "createIdDataviews", "parameters": [{ "name": "number", "type": "number", "description": "please determine the lenght of ID" } ], "result": { "type": "text", "description": "returns database id" } }
Custom Codefunction createIdDataviews(number) {
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
let dataviewID = " ";
let idLenght = number;
for (let i = 0; i < idLenght; i++) {
dataviewID += characters.charAt(Math.floor(Math.random() * characters.length))
}
return dataviewID
}