https://github.com/digicorp/id-management-module
id-management-module is used to generate unique id(key) based on some rule.This rules are provided as a array of rules JSON.
https://github.com/digicorp/id-management-module
Last synced: 11 months ago
JSON representation
id-management-module is used to generate unique id(key) based on some rule.This rules are provided as a array of rules JSON.
- Host: GitHub
- URL: https://github.com/digicorp/id-management-module
- Owner: digicorp
- Created: 2016-10-14T08:51:13.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-10-17T06:30:28.000Z (about 9 years ago)
- Last Synced: 2025-02-13T16:48:49.612Z (11 months ago)
- Language: JavaScript
- Size: 5.57 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## id-management-module
#### Author: Chandrakant Thakkar
##### Created on: 14th Oct 2016
---
###### id-management-module is used to generate unique id(key) based on some rule.This rules are provided as a array of rules JSON.
- This unique key may be consist of from static value,dynamic value,contains current date/time or contains user given date/time and format.
- Rule's array for static value
```javascript
var keyRule = [{
type: "static",
value: "UNIQUEKEY"
}];
var generateUniqueId = require('id-management-module');
var uniqueKey=generateUniqueId.generateID(keyRule);
```
- Here, it will generate key with value 'UNIQUEKEY' and return same.
- Rule's array for static value and dynamic value
```javascript
var keyRule = [{
type: "static",
value: "UNIQUEKEY"
}, {
type: "dynamic",
value: "plantCode"
}];
var data={
plantCode:"3001"
};
var generateUniqueId = require('id-management-module');
var uniqueKey=generateUniqueId.generateID(keyRule,data);
```
- Here, it will take static value 'UNIQUEKEY' from static rule and take dynamic value '3001' from plantCode passed into data.And it will return key 'UNIQUEKEY3001'.
- Rule's array for static value and dynamic value with current Date/Time
```javascript
var keyRule = [{
type: "static",
value: "UNIQUEKEY"
}, {
type: "dynamic",
value: "plantCode"
}, {
type: "currdatetime",
format: "%y%m%d"
}];
var data={
plantCode:"3001"
};
var generateUniqueId = require('id-management-module');
var uniqueKey=generateUniqueId.generateID(keyRule,data);
```
- Here, it will take static value 'UNIQUEKEY' from static rule and take dynamic value '3001' from plantCode passed into data and current date/time in YYYYMMDD format.And it will return key 'UNIQUEKEY300120161014'.
- Rule's array for static value and dynamic value with user defined Date/Time
```javascript
var keyRule = [{
type: "static",
value: "UNIQUEKEY"
}, {
type: "dynamic",
value: "plantCode"
}, {
type: "userdatetime",
format: "%y%m%d",
value:"2016-10-14"
}];
var data={
plantCode:"3001"
};
var generateUniqueId = require('id-management-module');
var uniqueKey=generateUniqueId.generateID(keyRule,data);
```
- Here, it will take static value 'UNIQUEKEY' from static rule and take dynamic value '3001' from plantCode passed into data and user defined date/time in YYYYMMDD format.And it will return key 'UNIQUEKEY300120161014'.