Does Meteor support MongoDB's DBRef?


I’d like to use the DBRef feature to resolve a foreign key relationship from one Collection to another. I succeeded in inserting a DBRef into the database, but it is not automatically resolved on retrieval (using find()). Is there a way I can trigger the resolution of a DBRef in Meteor, so that the resulting document automatically includes the referenced data as a sub-document? Somewhere I read that the Node.js driver for MongoDB would support this.


i am surprised there has been no answer so far. i am tempted to put this question on stackexchange instead, but this seems to be a far more appropriate forum.


Seems as if nobody is using this DBRef feature (or unaware that it exists).


hey - since you and i are talking to ourselves :wink: think you can answer a quick question for me? i am thinking that mongodb DBRef will be a nice substitute for my beloved mysql “foreign key” relationships. i have tables (oops, COLLECTIONS, sorry) that have might two parents or more parents, where the child record contains the unique id of each parent, thereby enforcing referential integrity. if this is considered too “off topic” for this forum, please contact me at mark at edwardsmark dot com - thanks.


Hi Mark,

don’t think this is off-topic, so I am answering directly (until some of the Meteor guys tell me this forum is not meant for private discussions, but hey, if nobody else is answering to my post… :smile:)

Regarding your question: Yes, that’s what I wanted to use these DBRefs for as well, and I also think, they are meant for this kind of usage to some extent.

Maybe you already know it, but there’s a quite decent documentation on the MongoDB website about data modelling with Mongo: It helped me a lot to understand how Mongo sees the database world.

Although coming from a relational background, I can “buy” the idea to not have “real” foreign keys, for the sake of being much more flexible with an open document-oriented model. But what really concerns me is that MongoDB does not have a transaction concept. Simulating this using document versioning does not really convince me so far, since this is quite error-prone, and I do not want to risk data loss in my application scenario. And what also concerns me is that I’m quite often hearing that people are losing data due to Mongo hickups. I am not sure if this is really a problem with Mongo itself or with inappropriate management, but Kadira’s blackout was another warning signal I’ve clearly heard. But that’s way off-topic now :smile:


hey - thank you very much for your reply.

i am a very SLOW LEARNER (extremely slow, excruciatingly painfully slow) so i will have to crawl through that modeling URL at a snails pace. yes i did see that before and saved it for future reference.

right now i am still evaluating mongoDB, mainly because i really like what i see in meteor. however (always a however, though) i am also looking at firebase. so both are under review. firebase as something REALLY cool where you can see (and edit) your data in any browser window. but mongoDB (the latest version anyways) has DBRef.

i also heard about the data-loss issue. maybe its just because mongoDB is so new? i run a mysqldump nightly for the mysql (mariadb) stuff, i am guessing that a JSON export does the same thing (that’s just an ignorant guess)


Also got a recommendation from a software architect to use Firebase, seems to be a good piece of software. But as Meteor is stuck to Mongo, I’m using this for now. ATM, speed is most important to me, so I take what works and gets me forward :smile:


hey - it seems that firebase and angularJS are pretty tight - i know google supports both. angularJS has a bit of a learning curve, so i have been warned.

so, meteor & mongoDB? or, angularJS & firebase ? and please dont answer “why not both!” :slight_smile:

i have been picking the brain of the owner of - they were using meteor but switched to firebase. how somebody can make transitions like that quickly is way beyond me.


Regarding the question meteor/mongo vs. angular/firebase, I can only provide my personal gut-feeling. I tried to delve into Angular and initially liked the concept, but the deeper I dived, the worse I felt about it’s uber-sophistication. So I made a side-step to Aurelia, which I really liked, but it was not mature and quite slow. This was the reason why I kept on searching for another framework and delved deeper into Meteor. I had some problems in the beginning with Meteor as well (in fact they nearly made me go away), because I tried to stick to my used-to procedures and I did not get that a full-stack approach requires some “re-thinking”. Yet, after taking these initial hurdles, I have to say: Meteor is just great. As far as I can tell, if you’re going the angular/firebase way, you would be lacking a lot of the full-stack integration Meteor offers. Angular is a front-end framework and Firebase is a hosted database; beyond that, Meteor is offering latency compensation, offline capabilities, integration with Cordova for building mobile applications and much more. Using angular/firebase, you would have to build many of these things yourself, using additional frameworks like Express etc. Meteor “just works”, and the development speed you gain with this full-stack integration is just awesome. I wouldn’t say I’m already an evangelist for Meteor, but I am convinced it is one of the most advanced frameworks these days. The only “problem” I see at the moment, is that Meteor is quite young and still “experimenting” a lot (and trying to embrace a lot of redundant technology like Angular and React), so you cannot be really sure if the decisions you make (e.g. by choosing a specific package) will hold for long. But anyway, at the moment I don’t see any alternative to gain the same development speeds, and this is the most important factor for me at the moment, since I’m trying to start my own business as a one-man-show :smile:


Regarding luzme: I only scratched the surface of their home page, but it doesn’t seem to be a really complex application. Maybe that’s the reason why they could switch frameworks that quickly?


hey - could you pls. write me at zzyzx15zzyzx-meteor(at)yahoo(dot)com ? thanks.


Hi Mark, sent you a PM to the mailinator account you sent me first. Did you receive it?