Skip to content

Commit

Permalink
move $populate parameter to params
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelErmer committed Jul 24, 2017
1 parent a8c2c09 commit 563b051
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/populate/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
'use strict'
module.exports.compatibility = function(options) {
return function(hook) {
// move query to params
if (hook && hook.params && hook.params.query && hook.params.query.$populate) {
hook.params.$populate = hook.params.query.$populate;
delete hook.params.query.$populate;
}
return hook;
};
};

module.exports = function populate (options) {
/**
Expand Down Expand Up @@ -45,6 +35,9 @@ module.exports = function populate (options) {
* set query.$populate to false to block all populates
**/
let skip = {};
if (hook.params.$populate==='false' || hook.params.$populate==='0' || hook.params.$populate===0) {
hook.params.$populate = false;
}
if (hook.params.$populate || hook.params.$populate===false) {
if (hook.params.$populate.constructor === Object) {
Object.keys(hook.params.$populate).map(function(key) {
Expand Down Expand Up @@ -102,3 +95,14 @@ module.exports = function populate (options) {
return hook;
};
};

module.exports.compatibility = function(options) {
return function(hook) {
// move query to params
if (hook && hook.params && hook.params.query && hook.params.query.$populate) {
hook.params.$populate = hook.params.query.$populate;
delete hook.params.query.$populate;
}
return hook;
};
};

0 comments on commit 563b051

Please sign in to comment.