Skip to content

Commit 89236e5

Browse files
committed
fix: ObjectId use new Date(new Date().toISOString()).getTime() instead of date.now() preventing 24 possible collisions in a day
1 parent feee696 commit 89236e5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
}
6060

6161
// Generate a new custom ObjectId
62-
const timestampHex = Math.floor(Date.now() / 1000).toString(16).padStart(8, '0');
62+
const timestampHex = Math.floor(new Date(new Date().toISOString()).getTime() / 1000).toString(16).padStart(8, '0');
6363
const processIdHex = Math.floor(Math.random() * 0x100000000000).toString(16).padStart(12, '0');
6464

6565
counter = (counter + 1) % 10000;

0 commit comments

Comments
 (0)