0

I am using Sails Js and MongoDB database. I want to optimize below Query.

Users.findOne({id:user_id})
    .populate('educations')
    .populate('educations.educationlinks')
    .populate('educations.educationlinks.verify_request_id')
    .populate('educations.educationlinks.verify_request_id.user_id')
.populate('educations.educationlinks.verify_request_id.user_id.company_id')
    .exec(function(err, user){
        return res.json(user);
});

Please Help Me.....

1 Answers1

0

By default, SailsJS doesn't use case sensitivity for MongoDB queries. To optimize MongoDB query performance, try forcing case sensitivity in your Mongo query code (MongoDB code in the connections .js file) with:

  wlNext: {
      caseSensitive: true
   }

//For Example:
    someMongodbServer: {
      adapter: 'sails-mongo',
      host: 'localhost',
      port: 27017,
      database: 'sails_demo' //optional
      wlNext: {
          caseSensitive: true
       }
    },

Hope this helps!

Additional resources:

https://docs.mongodb.com/manual/tutorial/optimize-query-performance-with-indexes-and-projections/

johnabrams7
  • 399
  • 2
  • 10