added explicitSinceSource as model option and only set source to query if option set to true

This commit is contained in:
mrjrdnthms 2017-02-07 15:39:48 -08:00
parent 01f41614dd
commit 4ea8c29bd2
1 changed files with 12 additions and 6 deletions

View File

@ -893,18 +893,24 @@ module.exports = function(registry) {
} }
if (options.trackChanges || options.enableRemoteReplication) { if (options.trackChanges || options.enableRemoteReplication) {
setRemoting(PersistedModel, 'diff', { var diffOptions = {
description: 'Get a set of deltas and conflicts since the given checkpoint.', description: 'Get a set of deltas and conflicts since the given checkpoint.',
accessType: 'READ', accessType: 'READ',
accepts: [ accepts: [
{ arg: 'since', type: 'number', description: 'Find deltas since this checkpoint', {arg: 'since', type: 'number', description: 'Find deltas since this checkpoint'},
http: { source: 'form' }}, {arg: 'remoteChanges', type: 'array', description: 'an array of change objects',
{ arg: 'remoteChanges', type: 'array', description: 'an array of change objects', http: {source: 'body'}},
http: { source: 'form' }}
], ],
returns: {arg: 'result', type: 'object', root: true}, returns: {arg: 'result', type: 'object', root: true},
http: {verb: 'post', path: '/diff'}, 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', { setRemoting(PersistedModel, 'changes', {
description: 'Get the changes to a model since a given checkpoint.' + description: 'Get the changes to a model since a given checkpoint.' +