$ npm i egg-snowflake-js --save
egg-snowflake-js version | egg 1.x |
---|---|
1.x | 😁 |
// {app_root}/config/plugin.js
exports.snowflake = {
enable: true,
package: 'egg-snowflake-js',
};
// {app_root}/config/config.default.js
exports.snowflake = {
client: {
workerId: 1, //1 to 31 int number. If do not set workerId, it will set a random number from 1 to 31
machineId: 1 //1 to 31 int number. If do not set machineId, it will set a int number(1 to 31) from hostname lenth
}
};
see config/config.default.js for more detail.
//{app_root}/app/controller/index.js
async index() {
const app = this.app;
const flakeId = app.snowflake.next();
console.log(flakeId)
}
Please open an issue here.