1

Association auto population is sexy during the early stages of the app development. Soon as the related models result in high number of associated records the api calls get a drastic performance hit. SailsJS provides a way to toggle this globally.

module.exports.blueprints.populate = true / false;

Ideal application would be to disable this option globally and load the related models on demand , is this possible ( Base use case would be how Laravel does things with Eager loading http://laravel.com/docs/5.0/eloquent#eager-loading ).

Gayan Hewa
  • 2,277
  • 4
  • 22
  • 41

1 Answers1

2

You should be able to override the blueprint configuration per controller #/disabling-blueprints-on-a-per-controller-basis

You may also override any of the settings from config/blueprints.js on a per-controller basis by defining a '_config' key in your controller defintion, and assigning it a configuration object with overrides for the settings in this file.

Try this in the controller where you want to activate populate:

module.exports = {
  _config: {
    populate: true
  }
}
Alexis N-o
  • 3,954
  • 26
  • 34
  • Yeah , but i am looking for more fine gained control. For an example , when I have multiple associated models , I want it to populate for a 1/2 rest calls depending on a query string ( For an example ) – Gayan Hewa Jul 19 '15 at 05:45
  • 1
    I think you can have a look at [this answer then](https://stackoverflow.com/questions/22273789/crud-blueprint-overriding-in-sails-js#answer-22274325) – Alexis N-o Jul 19 '15 at 12:07