{"id":43830,"library":"short-mongo-id","title":"short-mongo-id","description":"Generates short, URL-safe IDs from MongoDB ObjectIds using timestamp and counter components. Version 0.1.1 is a legacy package with no recent updates. Unlike base64 encoding, it produces compact alphanumeric strings but is one-way and should not be used for security or high-uniqueness requirements. Lightweight with zero dependencies.","status":"maintenance","version":"0.1.1","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","mongo","mongodb","short-id","shortener"],"install":[{"cmd":"npm install short-mongo-id","lang":"bash","label":"npm"},{"cmd":"yarn add short-mongo-id","lang":"bash","label":"yarn"},{"cmd":"pnpm add short-mongo-id","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package exports a default function. Named import will result in undefined.","wrong":"import { shortId } from 'short-mongo-id'","symbol":"default (function)","correct":"import shortId from 'short-mongo-id'"},{"note":"CommonJS require works directly; no destructuring needed.","wrong":"const { default: shortId } = require('short-mongo-id')","symbol":"default (require)","correct":"const shortId = require('short-mongo-id')"},{"note":"TypeScript definitions are not included; you may need to declare types manually.","wrong":"import shortId from 'short-mongo-id' // for types","symbol":"type import","correct":"import type { ShortMongoId } from 'short-mongo-id'"}],"quickstart":{"code":"import shortId from 'short-mongo-id';\n\nconst mongoId = '507f191e810c19729de860ea';\nconst short = shortId(mongoId);\nconsole.log(short); // e.g., 'iTxuMF'","lang":"typescript","description":"Converts a MongoDB ObjectId string into a short alphanumeric ID. Works with any valid ObjectId."},"warnings":[{"fix":"If you need to reverse, store the mapping separately.","message":"The short ID is not reversible; original ObjectId cannot be recovered.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider using nanoid or uuid with a custom transformation for modern needs.","message":"Package is no longer maintained; no updates since 2014.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Do not rely on this for primary keys or security tokens.","message":"Collisions are possible, though unlikely; uniqueness is not guaranteed.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Validate ObjectId before passing: use /^[a-f\\d]{24}$/i.test(id).","message":"Requires a valid MongoDB ObjectId string; non-conforming strings throw an error.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.1.1':20 'alphanumer':35 'base64':30 'compact':34 'compon':18 'counter':17 'depend':57 'encod':31 'generat':5 'high':51 'high-uniqu':50 'id':4,10,63 'javascript':58 'legaci':23 'lightweight':54 'mongo':3,59 'mongodb':12,60 'objectid':13 'one':40 'one-way':39 'packag':24 'produc':33 'recent':27 'requir':53 'safe':9 'secur':48 'short':2,6,62 'short-id':61 'short-mongo-id':1 'shorten':64 'string':36 'timestamp':15 'uniqu':52 'unlik':29 'updat':28 'url':8 'url-saf':7 'use':14,46 'version':19 'way':41 'zero':56","created_at":"2026-06-05T17:01:40.638661+00:00","updated_at":"2026-06-05T17:01:40.638661+00:00","problems":[{"fix":"Use `import shortId from 'short-mongo-id'` or `const shortId = require('short-mongo-id')`.","cause":"Using named import instead of default import.","error":"TypeError: shortId is not a function"},{"fix":"Ensure the input is a 24-character hex string representing a MongoDB ObjectId.","cause":"Passing an invalid format (non-hex, wrong length) to shortId.","error":"Error: Argument must be a valid Mongo ObjectId"},{"fix":"Run `npm install short-mongo-id`.","cause":"Package not installed or not in node_modules.","error":"Cannot find module 'short-mongo-id'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"short-mongo-id","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}