3 ms·
This looks like the first half of a blog post... it's just a list of a few drivers you can use in Node to connect to MongoDB. Am I missing something?
by icey 16y ago
This looks like the first half of a blog post... it's just a list of a few drivers you can use in Node to connect to MongoDB. Am I missing something?
- deleted 16y ago[deleted]
- yesbabyyes 16y agoI agree. I have experimented quite a bit with Node + MongoDB, and we chose Mongoose when they made their first announcement. It's been a little bumpy ride, with fast-changing APIs on all fronts, but that's to be expected with so young technology. Overall I think Mongoose definitely brings some value, but it's still quite convoluted how you do queries, in my experience. The querying seems to be heavily influenced from Django's ORM, where you work with Query Promises which you can chain together, so you will do stuff like: Collection.find({published: true}).sort().skip(20).limit(20) And then the whole query is lazily executed. When playing with MongoDB and Node I recently got an idea: JavaScript 1.6's Array prototype has some pretty powerful methods for sorting, filtering, map/reduce and so on. Maybe it would be desirable to create a layer on top of MongoDB that implements this interface, so you could build your app using builtin datastructures (typically objects in arrays) and then just connect it to MongoDB, and that's that? var posts = []; // Do something to connect posts to a MongoDB collection var published = posts .sort(function(a, b) { return a.publish_date < b.publish_date ? -1 : a.publish_date == b.publish_date ? 0 : 1; }) .filter(function(post) { return post.published; }); posts.push(newPost); And so on. What do you think?