{"id":14974024,"url":"https://github.com/sqids/sqids-plpgsql","last_synced_at":"2025-10-27T05:31:26.587Z","repository":{"id":176746992,"uuid":"658044266","full_name":"sqids/sqids-plpgsql","owner":"sqids","description":"Official PLpgSQL (PostgreSQL) port of Sqids. Generate short unique IDs from numbers.","archived":false,"fork":false,"pushed_at":"2024-09-15T17:52:43.000Z","size":17,"stargazers_count":19,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-01T02:41:24.313Z","etag":null,"topics":["hashids","id","id-generator","pg","plpgsql","postgresql","short-id","short-url","sqids","uid","unique-id","unique-id-generator"],"latest_commit_sha":null,"homepage":"https://sqids.org/plpgsql","language":"PLpgSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sqids.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-06-24T15:36:40.000Z","updated_at":"2025-01-21T10:01:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"9489cbb5-6df9-48b1-98a5-2dd0995d02c7","html_url":"https://github.com/sqids/sqids-plpgsql","commit_stats":null,"previous_names":["sqids/sqids-plpgsql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqids%2Fsqids-plpgsql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqids%2Fsqids-plpgsql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqids%2Fsqids-plpgsql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sqids%2Fsqids-plpgsql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sqids","download_url":"https://codeload.github.com/sqids/sqids-plpgsql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238445839,"owners_count":19473821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hashids","id","id-generator","pg","plpgsql","postgresql","short-id","short-url","sqids","uid","unique-id","unique-id-generator"],"created_at":"2024-09-24T13:49:50.442Z","updated_at":"2025-10-27T05:31:26.259Z","avatar_url":"https://github.com/sqids.png","language":"PLpgSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Sqids PLpgSQL](https://sqids.org/plpgsql)\n\n[Sqids](https://sqids.org/plpgsql) (pronounced \"squids\") is a small library that lets you **generate unique IDs from numbers**. It's good for link shortening, fast \u0026 URL-safe ID generation and decoding back into numbers for quicker database lookups.\n\nFeatures:\n\n- **Encode multiple numbers** - generate short IDs from one or several non-negative numbers\n- **Quick decoding** - easily decode IDs back into numbers\n- **Unique IDs** - generate unique IDs by shuffling the alphabet once\n- **ID padding** - provide minimum length to make IDs more uniform\n- **URL safe** - auto-generated IDs do not contain common profanity\n- **Randomized output** - Sequential input provides nonconsecutive IDs\n- **Many implementations** - Support for [40+ programming languages](https://sqids.org/)\n\n## 🧰 Use-cases\n\nGood for:\n\n- Generating IDs for public URLs (eg: link shortening)\n- Generating IDs for internal systems (eg: event tracking)\n- Decoding for quicker database lookups (eg: by primary keys)\n\nNot good for:\n\n- Sensitive data (this is not an encryption library)\n- User IDs (can be decoded revealing user count)\n\n## 🚀 Getting started\n\n### Important notes\n\n\u003e **Note**\n\u003e 🚧 The `src/install.sql` file is idempotent but destructive. It will `DROP SCHEMA sqids` so be sure you aren't using a schema with that name!\n\nThe blocklist is stored in a table. If you need it to somehow be dynamic per-call, you can likely use transactions, but I have not tested it.\n\n### Compatibility\n\nWritten \u0026 tested on Postgres 15.6. The functions used are pretty simple - it will likely work on 9+ (definitely not earlier). Be sure to install \u0026 run tests!\n\n### Installation\n\nSimply run `src/install.sql` on your database.\n\n## 👩‍💻 Examples\n\nAfter install, use encode \u0026 decode:\n\nencode takes an array of BIGINT, an alphabet, and an optional minLength.\n\n```sql\nselect sqids.encode(array[123, 456, 789], 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 12); -- EBDQWDLPCTHG\n```\n\ndecode requires the id and alphabet. It returns an array of BIGINT.\n\n```sql\nselect sqids.decode('EBDQWDLPCTHG', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'); -- {123,456,789}\n```\n\n### With default alphabet \u0026 min length (0)\n\n```sql\nselect sqids.encode(array[123, 456, 789]); --eVH6til6J\n```\n\n### With default alphabet \u0026 custom min length\n\n```sql\nselect sqids.encode(array[123, 456, 789], 12); --eVH6til6J03E\n```\n\n### Decode with default alphabet\n\n```sql\nselect sqids.decode('eVH6til6J03E'); -- {123,456,789}\n```\n\n## 🧪 Testing\n\nRun the sql files in tests dir to install.\n\nThen run:\n\n```sql\nselect sqids.alphabet_test();\nselect sqids.blocklist_test();\nselect sqids.encoding_test();\nselect sqids.minlength_test();\n```\n\n## 📝 License\n\n[MIT](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqids%2Fsqids-plpgsql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsqids%2Fsqids-plpgsql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsqids%2Fsqids-plpgsql/lists"}