Generate a short unique ID from the integer for ThinkJS base on hashids
npm install think-hashids --save
const hashids = require('think-hashids')
module.exports = [
hashids({
salt: 'this is salt',
minLength: 10,
alphabet: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
})
];
salt
: Participate in the calculated salt. Default:''
minLength
: The minimum length of the resulting result. Default:0
alphabet
: Generates the resulting character set .Default:'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
this.encode(id)
: Encode IDthis.decode(id)
: Decode IDthis.encodeHex(id)
: Encode hex instead of numbersthis.decodeHex(id)
: Decode hex instead of numbers