Support for Mongo BSON UUIDs 馃崈 #11553
Replies: 2 comments 3 replies
-
I think if we talk about "support" it should be both, reading and writing. We have a similar urge but with native ObjectId, where we connect to an existing MongoDB from a plain node app and we would like not only to read their docs (which is working fine with a custom Related: meteor/meteor-feature-requests#428 (the intial post does not look like it's about native Mongo ObjectId but it's basically what's intended there). I think both of these use-cases are very close to each other |
Beta Was this translation helpful? Give feedback.
-
Anyone from mdg able to comment on whether a PR for part (1) of the above approach would be accepted? Our company's time window is narrowing for making a decision on contributing this support or going with some other workaround for the time being. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Our team is working with Mongo's BSON Binary UUIDs (sub-type 4), but we don't see a supported way to use them with Meteor. Meteor's
mongo
andejson
packages seem to work withUint8Array
and persist them to the default Binary type (sub-type 0).Unless we are overlooking an existing solution, we are open to contributing UUID support, but would first need to confirm the scope of what an acceptable implementation might look like.
Proposal
Add hooks to
mongo/mongo_driver.js
which allow overriding the handling of certain data types inreplaceMongoAtomWithMeteor
andreplaceMeteorAtomWithMongo
.Contribute a package that allows optional UUID support by using these hooks to handle UUIDs similar to
ObjectID
. This package would:Mongo.UUID
class and EJSON custom type similar toMongo.ObjectID
{ $type: 'uuid', $value: <hex_string> }
Mongo.UUID
instead ofUint8Array
Mongo.UUID
to Binary sub-type 4 instead of sub-type 0Any feedback on likely difficulties to overcome or preferred implementation would be greatly appreciated.
Related: We are not looking to add support for UUIDs for ID generation, as has been requested in these other feature requests, but this might be a partial step towards support:
Beta Was this translation helpful? Give feedback.
All reactions