- fix: objectId in javascript, and not created by Mongodb
This commit is contained in:
10
src/js/objectId.js
Normal file
10
src/js/objectId.js
Normal 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
|
||||
Reference in New Issue
Block a user