Skip to content

Commit 9318c96

Browse files
committed
update readme
Signed-off-by: Utkarsh Srivastava <srivastavautkarsh8097@gmail.com>
1 parent 83f2a2a commit 9318c96

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66

77
nodejs-snowflake is a fast and reliable way to generate time sortable 64 bit ids written for distributed systems.
88
The main id generation function is written in C++ using N-API which makes the process of id generation extremely fast. The usage of C++ for id generation also guaratees that the generated number will be of size 64 bits.
9-
**Now Supports machine id extraction from the generated ids, even if they were generated on different machines**
9+
10+
**Version 1.6 Updates**
11+
- Add `GetIDFromTimestamp` function which can be used in database queries.
12+
13+
**Version 1.5 Updates**
14+
- Add `GetMachineIDFromTimestamp` help extracting machine id from the generated ids, even if they were generated on different machines
1015

1116
## How to install
1217

@@ -92,6 +97,18 @@ console.log(mid); // 2345 -> This is the 12 bit long machine id where this token
9297

9398
```
9499

100+
### Get ID corresponding to a Timestamp
101+
This can be extremely helpful in writing database queries where the requirement could be to get entries created after a certain timestamp.
102+
103+
```javascript
104+
...
105+
106+
const id = uid.IDFromTimestamp(Date.now()); // Here id will always be BigInt
107+
108+
console.log(id); // A 64 bit id is returned corresponding to the timestamp given
109+
110+
```
111+
95112
### Get the current machine id
96113
This solely exits to find the machine id of current machine in case the user didn't provided as machine id and relied on the randomly generated value.
97114

0 commit comments

Comments
 (0)