Skip to content

TheHippo/mongodb-short-id

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MongoDB short id

Create shorter string from MongoDB objectIDs and reverse

Api Examples

var shortID = require('mongodb-short-id');

shortID.longToShort('507f1f77bcf86cd799439011');
// => 'UH8fd7z4bNeZQ5AR'

shortID.shortToLong('UH8fd7z4bNeZQ5AR');
// => '507f1f77bcf86cd799439011'

shortID.shortToObjectID('UH8fd7z4bNeZQ5AR');
// => 507f1f77bcf86cd799439011
typeof shortID.shortToObjectID('UH8fd7z4bNeZQ5AR');
// => 'object'

var objectID = shortID.shortToObjectID('UH8fd7z4bNeZQ5AR');
shortID.objectIDToShort(objectID)
// => 'UH8fd7z4bNeZQ5AR'

Shortcuts

  • l2s => longToShort
  • s2l => shortToLong
  • o2s => objectIDtoShort
  • s2o => shortToObjectID

Build status

  • master: Build Status
  • develop: Build Status

About

Convert MongoDB ID to shorter strings and reverse

Resources

License

Stars

Watchers

Forks

Packages

No packages published