The longer ID does seem like it would have have merit, and maybe using the default Mongo approach would make it easier to switch the back end stack if one needed to?
I’m curious what you guys think. I’m about to put something in production and am debating if it’s worth fixing this up
As far as I know there is no advantage at all to use IDs generated by Mongo over Meteor’s. Also you will lose the optimistic UI for inserts since that relies on IDs being generated in the client.
That’s a fair trade off. On that subject, how does one generate Meteor id’s these days? I tried using Random but it looks like it’s no longer available
@shock@msavin the method described in that post does not product actual mongodb object id’s and they do not contain natural sort order or timestamp information.
they are random strings wrapped in an ObjectID() constructor.
@sashko that’s right, this is already built in to meteor, given the generated id has no meaning. If you ever want to take a stab at this though, there’s this very old issue about the accounts system not supporting objectid at all
My data schema draws from MongoDb best practices where the user id is composed by base64 encoding MongoDb’s objectid. I’m having problems with is because meteor’s user accounts collection doesn’t support mongodb id generation (to me this seems like a non-trivial limitation). My user document has several nested fields and participates in several more one to many relationships with documents from other collections. From what I’ve read, my case seems like one where I should avoid the user accounts profile field. My question, should I customize the users collection or should I establish a separate userProfiles collection? For instance
Meteor User Accounts collection
user._id : ‘string’ // meteor generated id
…
User Profile collection
userProfile._id: ‘ObejectId(…)’ // mongodb generated id
userProfile.user_id: 'base64 (userProfile._id)'
userProfile.meteor_id: ‘Meteor.user()’ // fk reference to meteor accounts
…
Other related collections
…
user_id: ‘userProfile.user_id’ // fk reference.
Thanks in advance. Btw, I ask the question here because I was lead to this tread by following @awatson1978 post. I also read a remark by @sashko that it might be best to creat a separate collection to hold nested user profile data.