- fix: objectId in javascript, and not created by Mongodb

This commit is contained in:
Paolo Arena
2019-02-03 03:44:25 +01:00
parent 5d987013c5
commit 990955b6c2
5 changed files with 44 additions and 22 deletions

10
src/js/objectId.js Normal file
View File

@@ -0,0 +1,10 @@
function objectId () {
return hex(Date.now() / 1000) +
' '.repeat(16).replace(/./g, () => hex(Math.random() * 16))
}
function hex (value) {
return Math.floor(value).toString(16)
}
export default objectId