{"repo":"viascom/nanoid-mysql-mariadb","free":true,"listed":false,"github":"https://github.com/viascom/nanoid-mysql-mariadb","clone":"git clone https://github.com/viascom/nanoid-mysql-mariadb.git","description":"Nano ID for MySQL / MariaDB","language":"Shell","stars":26,"topics":["database","mariadb","mysql","nanoid"],"license":"Apache-2.0","category":"databases-storage","readme_excerpt":"Nano ID for MySQL / MariaDB Inspired by the following parent project: ai/nanoid A tiny, secure, URL-friendly, unique string ID generator for MySQL / MariaDB. “An amazing level of senseless perfectionism, which is simply impossible not to respect.” Small. Just a simple MySQL/MariaDB function. Safe. It uses the RANDOM BYTES() random generator. Can be used in clusters. Short IDs. It uses a larger alphabet than UUID ( A-Za-z0-9 - ). So ID size was reduced from 36 to 21 symbols. Portable . Nano ID was ported to over 20 programming languages. How to use Prefixed ids The optional prefix parameter of nanoid custom() and nanoid prefixed() prepends a fixed marker to every generated id, so anyone looking at an id can immediately tell which entity it belongs to ( usr , ord , ...). The prefix does not count towards size : the total id length is CHAR LENGTH(prefix) + size , so size your columns accordingly (for example VARCHAR(25) for the default size of 21 plus the 4-character prefix usr ). A NULL prefix behaves like an empty prefix. Unlike PostgreSQL, MySQL and MariaDB do not allow stored functions in DEFAULT expressions, so use the trigger setup below for automatic id generation. Auto ID Generation with Triggers This guide shows how to set up triggers for auto-generating unique IDs using our function nanoid() . Prerequisites You should have already created the function nanoid() that generates unique identifiers. Creating a Trigger A trigger auto-executes certain instructions on database","default_branch":null,"files":null,"tree":[],"storefront":"/r/viascom","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/viascom/nanoid-mysql-mariadb/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}