Comments (6)
Please read the README description https://github.com/williamkapke/bson-objectid#bson-objectid-
https://github.com/williamkapke/bson-objectid/blob/master/objectid.js#L241-L274 versus https://github.com/mongodb/js-bson/blob/da8d8f1c0a9eaff7df6468a77e98282b8456cc3a/lib/bson/objectid.js#L151-L182
PR welcome for improvements
from bson-objectid.
We recently encountered a big flaw in our database because this library is not able to generate a globally unique id. Can't rely on it unless the author comes and comment.
from bson-objectid.
This library uses timestamps as that's the underlying mechanism.
Ref: https://github.com/williamkapke/bson-objectid/blob/master/objectid.js#L242-L252
For something unique you should use uuid
or something else.
from bson-objectid.
Thanks for the clarification @titanism. Curious to know, how this is different from https://github.com/mongodb/js-bson/blob/1.0-branch/lib/bson/objectid.js?
from bson-objectid.
This library implements the same logic as Mongo's bson-objectid (see links above).
ObjectID can be considered globally unique for all practical purposes.
All globally unique methods have some possibility of duplicates- it's just a matter of making it a really small chance. Everyone needs to identify how extreme their definition of "small chance" is. For Mongo- they're saying their algorithm covers "all practical purposes."
That's certainly open for interpretation!
from bson-objectid.
Thanks, @williamkapke for jumping in and replying. You are right, Everyone needs to identify how extreme their definition of "small chance" is..
For us (where we offer a GA-like analytics SDK), we got ~950 duplicate identifiers. Upon investigation, we found that when our customers (who are using our SDK) websites when crawled by Google on daily basis, it was generating duplicate IDs very frequently that these 950 duplicates were generated just between 10th May to 6th of July.
We are assuming that this is because they must be using a hardware blueprint to launch multiple virtual devices.
from bson-objectid.
Related Issues (20)
- Publishing `.idea` folder to npm HOT 1
- Can you make this work in a browser? HOT 1
- Typescript errors HOT 3
- Cannot get version 1.2.4 from npm HOT 2
- Wrong typing for getTimestamp() HOT 1
- ObjectID.isValid should check that `typeof toString === 'function'` otherwise if it's not an object and doesn't have a `toString` then it would return false HOT 5
- No changelog HOT 2
- A vulnerability in ObjectID() HOT 11
- Cannot use namespace 'Buffer' as a type. HOT 3
- Typescript import issue HOT 2
- Types have not been updated and ObjectId.generate is no longer being exported HOT 2
- ObjectID.isValid function return true for number HOT 7
- Api is not matching the one from `bson` - `createFromTime` HOT 1
- Api is not matching the one from `bson` - `getTimestamp` HOT 4
- Getter ObjectID.str returns undefined HOT 1
- IsValid returns true for invalid binary data HOT 2
- Uncaught ReferenceError: _Buffer is not defined HOT 2
- Type for ObjectID does not match mongodb ObjectId HOT 1
- Buffer types are not checked properly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bson-objectid.