From a863a810a8d852f9fb1fa323430f03e8d4e45fac Mon Sep 17 00:00:00 2001 From: YChebotaev Date: Wed, 24 Feb 2016 01:55:58 +0500 Subject: [PATCH] Workaround for #219 Added `populateForce` property to extend sails-permissions behaviour. --- api/hooks/permissions/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/api/hooks/permissions/index.js b/api/hooks/permissions/index.js index d37f8d9..f8ba89f 100644 --- a/api/hooks/permissions/index.js +++ b/api/hooks/permissions/index.js @@ -19,9 +19,18 @@ class Permissions extends Marlinspike { if (!_.isObject(sails.config.permissions)) sails.config.permissions = { } /** - * Local cache of Model name -> id mappings to avoid excessive database lookups. + * workaround for #219: + * If your _actually_ want to populate blueprint models, you should set `populateForce` filed in config */ - this.sails.config.blueprints.populate = false + var populateForce = this.sails.config.blueprints.populateForce; + if (populateForce) { + this.sails.config.blueprints.populate = !!populateForce; + } else { + /** + * Local cache of Model name -> id mappings to avoid excessive database lookups. + */ + this.sails.config.blueprints.populate = false + } } initialize (next) {