From 01f41614dd6086b2552385affafcf9ad6f013957 Mon Sep 17 00:00:00 2001 From: mrjrdnthms Date: Mon, 6 Feb 2017 14:53:56 -0800 Subject: [PATCH 1/3] setRemoting is defined for remoteChanges with http: { source: 'body' }, and 'since' is not. strong-remoting only sets one parameter in the request body when it's defined like this. Fixed this bug by sending both params through form. https://github.com/strongloop/loopback/issues/3188 --- lib/persisted-model.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/persisted-model.js b/lib/persisted-model.js index df52fad7..9f00fa1c 100644 --- a/lib/persisted-model.js +++ b/lib/persisted-model.js @@ -897,9 +897,10 @@ module.exports = function(registry) { description: 'Get a set of deltas and conflicts since the given checkpoint.', accessType: 'READ', accepts: [ - {arg: 'since', type: 'number', description: 'Find deltas since this checkpoint'}, - {arg: 'remoteChanges', type: 'array', description: 'an array of change objects', - http: {source: 'body'}}, + { arg: 'since', type: 'number', description: 'Find deltas since this checkpoint', + http: { source: 'form' }}, + { arg: 'remoteChanges', type: 'array', description: 'an array of change objects', + http: { source: 'form' }} ], returns: {arg: 'result', type: 'object', root: true}, http: {verb: 'post', path: '/diff'}, From 4ea8c29bd2b62c5eaea34c3d7b4cd1d99642045b Mon Sep 17 00:00:00 2001 From: mrjrdnthms Date: Tue, 7 Feb 2017 15:39:48 -0800 Subject: [PATCH 2/3] added explicitSinceSource as model option and only set source to query if option set to true --- lib/persisted-model.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/persisted-model.js b/lib/persisted-model.js index 9f00fa1c..af1eb2bd 100644 --- a/lib/persisted-model.js +++ b/lib/persisted-model.js @@ -893,18 +893,24 @@ module.exports = function(registry) { } if (options.trackChanges || options.enableRemoteReplication) { - setRemoting(PersistedModel, 'diff', { + var diffOptions = { description: 'Get a set of deltas and conflicts since the given checkpoint.', accessType: 'READ', accepts: [ - { arg: 'since', type: 'number', description: 'Find deltas since this checkpoint', - http: { source: 'form' }}, - { arg: 'remoteChanges', type: 'array', description: 'an array of change objects', - http: { source: 'form' }} + {arg: 'since', type: 'number', description: 'Find deltas since this checkpoint'}, + {arg: 'remoteChanges', type: 'array', description: 'an array of change objects', + http: {source: 'body'}}, ], returns: {arg: 'result', type: 'object', root: true}, http: {verb: 'post', path: '/diff'}, - }); + }; + // The since argument is not passed in remote requests + // set options.explicitSinceSource to true in model config + // to explicitly set argument source and ensure its passed + if (options.explicitSinceSource) { + diffOptions[0].accepts.http = {source: 'query'}; + } + setRemoting(PersistedModel, 'diff', diffOptions); setRemoting(PersistedModel, 'changes', { description: 'Get the changes to a model since a given checkpoint.' + From 9da564feef582de6c7633d0925f51ad0e11efa89 Mon Sep 17 00:00:00 2001 From: mrjrdnthms Date: Tue, 7 Feb 2017 16:08:55 -0800 Subject: [PATCH 3/3] typo fix incorrect array access --- lib/persisted-model.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/persisted-model.js b/lib/persisted-model.js index af1eb2bd..4e484f13 100644 --- a/lib/persisted-model.js +++ b/lib/persisted-model.js @@ -908,7 +908,7 @@ module.exports = function(registry) { // set options.explicitSinceSource to true in model config // to explicitly set argument source and ensure its passed if (options.explicitSinceSource) { - diffOptions[0].accepts.http = {source: 'query'}; + diffOptions.accepts[0].http = {source: 'query'}; } setRemoting(PersistedModel, 'diff', diffOptions);