How to use lean queries in MongoDb

Hi Everyone,

Have a look at this: Mongoose v5.13.0: Mongoose Tutorials: Faster Mongoose Queries With Lean

How can we use this with Meteor, Is there any way?

Collection.rawCollection().find()

1 Like

From what I can see lean queries is something specific to Mongoose, while Meteor builds on top of the official MongoDB driver, so you can’t go any leaner than @rjdavid suggested, but then you start loosing benefits of Meteor.

Can’t it be developed over our current Wrapper?

If you want to do it go ahead. Right now I have other things that I want to develop for the Meteor MongoDB implementation first.

I’ve used both Meteor and Mongoose extensively, in separate projects. @mixmatric, are you using Mongoose within a Meteor project?

Meteor mongo queries are always ‘lean’, by this definition. Meteor doesn’t wrap the results in a custom class, it doesn’t ‘hydrate’ the results by ‘joining’ data from other collection, or provide change tracking with .save() methods on the result object, or implement schema validation (other packages can add this functionality). Meteor mongo gives you the raw, lean, mongo result.

You don’t even need to use the .rawCollection property to get ‘lean’ results.

1 Like

It does not. The cursor result from Meteor is not the same cursor as returned by Mongodb

OK, but it doesn’t have all the ‘fat’ that Mongoose adds.

Out of curiosity, what’s different about the Meteor cursor compared to the raw cursor? Does it add much overhead?

The Mongo cursor (from the official driver) has mostly async query functions.

The Meteor version has all sync functions. It also removes a lot of mongo cursor functions and add meteor-specific ones