Created
September 24, 2018 17:39
-
-
Save ramyhhh/c0cf9b8653b8b2eedb33e9249ccc6829 to your computer and use it in GitHub Desktop.
Mongo ObjectId generator typescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ObjectIdGenerator { | |
static generate(): string { | |
let result = Math.round(new Date().getTime() / 1000).toString(16); | |
for (let i = 0; i < 16; i++) { | |
result += Math.round(Math.random() * 16).toString(16); | |
} | |
return result.substr(0,24); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment