You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-1Lines changed: 18 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,12 @@
6
6
7
7
nodejs-snowflake is a fast and reliable way to generate time sortable 64 bit ids written for distributed systems.
8
8
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
10
15
11
16
## How to install
12
17
@@ -92,6 +97,18 @@ console.log(mid); // 2345 -> This is the 12 bit long machine id where this token
92
97
93
98
```
94
99
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
+
constid=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
+
95
112
### Get the current machine id
96
113
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.
0 commit comments