Revert globalization of Swagger descriptions
This commit is contained in:
parent
6c9df360b9
commit
7932d75c44
|
@ -660,12 +660,12 @@ module.exports = function(User) {
|
||||||
UserModel.remoteMethod(
|
UserModel.remoteMethod(
|
||||||
'login',
|
'login',
|
||||||
{
|
{
|
||||||
description: g.f('Login a user with username/email and password.'),
|
description: 'Login a user with username/email and password.',
|
||||||
accepts: [
|
accepts: [
|
||||||
{arg: 'credentials', type: 'object', required: true, http: {source: 'body'}},
|
{arg: 'credentials', type: 'object', required: true, http: {source: 'body'}},
|
||||||
{arg: 'include', type: ['string'], http: {source: 'query'},
|
{arg: 'include', type: ['string'], http: {source: 'query'},
|
||||||
description: g.f('Related objects to include in the response. ' +
|
description: 'Related objects to include in the response. ' +
|
||||||
'See the description of return value for more details.') },
|
'See the description of return value for more details.' },
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
arg: 'accessToken', type: 'object', root: true,
|
arg: 'accessToken', type: 'object', root: true,
|
||||||
|
@ -683,15 +683,15 @@ module.exports = function(User) {
|
||||||
UserModel.remoteMethod(
|
UserModel.remoteMethod(
|
||||||
'logout',
|
'logout',
|
||||||
{
|
{
|
||||||
description: g.f('Logout a user with access token.'),
|
description: 'Logout a user with access token.',
|
||||||
accepts: [
|
accepts: [
|
||||||
{arg: 'access_token', type: 'string', required: true, http: function(ctx) {
|
{arg: 'access_token', type: 'string', required: true, http: function(ctx) {
|
||||||
var req = ctx && ctx.req;
|
var req = ctx && ctx.req;
|
||||||
var accessToken = req && req.accessToken;
|
var accessToken = req && req.accessToken;
|
||||||
var tokenID = accessToken && accessToken.id;
|
var tokenID = accessToken && accessToken.id;
|
||||||
return tokenID;
|
return tokenID;
|
||||||
}, description: g.f('Do not supply this argument, it is automatically extracted ' +
|
}, description: 'Do not supply this argument, it is automatically extracted ' +
|
||||||
'from request headers.'),
|
'from request headers.',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
http: {verb: 'all'}
|
http: {verb: 'all'}
|
||||||
|
@ -701,7 +701,7 @@ module.exports = function(User) {
|
||||||
UserModel.remoteMethod(
|
UserModel.remoteMethod(
|
||||||
'confirm',
|
'confirm',
|
||||||
{
|
{
|
||||||
description: g.f('Confirm a user registration with email verification token.'),
|
description: 'Confirm a user registration with email verification token.',
|
||||||
accepts: [
|
accepts: [
|
||||||
{arg: 'uid', type: 'string', required: true},
|
{arg: 'uid', type: 'string', required: true},
|
||||||
{arg: 'token', type: 'string', required: true},
|
{arg: 'token', type: 'string', required: true},
|
||||||
|
@ -714,7 +714,7 @@ module.exports = function(User) {
|
||||||
UserModel.remoteMethod(
|
UserModel.remoteMethod(
|
||||||
'resetPassword',
|
'resetPassword',
|
||||||
{
|
{
|
||||||
description: g.f('Reset password for a user with email.'),
|
description: 'Reset password for a user with email.',
|
||||||
accepts: [
|
accepts: [
|
||||||
{arg: 'options', type: 'object', required: true, http: {source: 'body'}}
|
{arg: 'options', type: 'object', required: true, http: {source: 'body'}}
|
||||||
],
|
],
|
||||||
|
|
47
lib/model.js
47
lib/model.js
|
@ -13,6 +13,7 @@ var assert = require('assert');
|
||||||
var RemoteObjects = require('strong-remoting');
|
var RemoteObjects = require('strong-remoting');
|
||||||
var SharedClass = require('strong-remoting').SharedClass;
|
var SharedClass = require('strong-remoting').SharedClass;
|
||||||
var extend = require('util')._extend;
|
var extend = require('util')._extend;
|
||||||
|
var format = require('util').format;
|
||||||
|
|
||||||
module.exports = function(registry) {
|
module.exports = function(registry) {
|
||||||
|
|
||||||
|
@ -452,7 +453,7 @@ module.exports = function(registry) {
|
||||||
http: {verb: 'get', path: '/' + pathName},
|
http: {verb: 'get', path: '/' + pathName},
|
||||||
accepts: {arg: 'refresh', type: 'boolean', http: {source: 'query'}},
|
accepts: {arg: 'refresh', type: 'boolean', http: {source: 'query'}},
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
description: g.f('Fetches belongsTo relation %s.', relationName),
|
description: format('Fetches belongsTo relation %s.', relationName),
|
||||||
returns: {arg: relationName, type: modelName, root: true},
|
returns: {arg: relationName, type: modelName, root: true},
|
||||||
}, fn);
|
}, fn);
|
||||||
};
|
};
|
||||||
|
@ -476,7 +477,7 @@ module.exports = function(registry) {
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
http: {verb: 'get', path: '/' + pathName},
|
http: {verb: 'get', path: '/' + pathName},
|
||||||
accepts: {arg: 'refresh', type: 'boolean', http: {source: 'query'}},
|
accepts: {arg: 'refresh', type: 'boolean', http: {source: 'query'}},
|
||||||
description: g.f('Fetches hasOne relation %s.', relationName),
|
description: format('Fetches hasOne relation %s.', relationName),
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
returns: {arg: relationName, type: relation.modelTo.modelName, root: true},
|
returns: {arg: relationName, type: relation.modelTo.modelName, root: true},
|
||||||
rest: {after: convertNullToNotFoundError.bind(null, toModelName)}
|
rest: {after: convertNullToNotFoundError.bind(null, toModelName)}
|
||||||
|
@ -486,7 +487,7 @@ module.exports = function(registry) {
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
http: {verb: 'post', path: '/' + pathName},
|
http: {verb: 'post', path: '/' + pathName},
|
||||||
accepts: {arg: 'data', type: toModelName, http: {source: 'body'}},
|
accepts: {arg: 'data', type: toModelName, http: {source: 'body'}},
|
||||||
description: g.f('Creates a new instance in %s of this model.', relationName),
|
description: format('Creates a new instance in %s of this model.', relationName),
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
returns: {arg: 'data', type: toModelName, root: true}
|
returns: {arg: 'data', type: toModelName, root: true}
|
||||||
});
|
});
|
||||||
|
@ -495,7 +496,7 @@ module.exports = function(registry) {
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
http: {verb: 'put', path: '/' + pathName},
|
http: {verb: 'put', path: '/' + pathName},
|
||||||
accepts: {arg: 'data', type: toModelName, http: {source: 'body'}},
|
accepts: {arg: 'data', type: toModelName, http: {source: 'body'}},
|
||||||
description: g.f('Update %s of this model.', relationName),
|
description: format('Update %s of this model.', relationName),
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
returns: {arg: 'data', type: toModelName, root: true}
|
returns: {arg: 'data', type: toModelName, root: true}
|
||||||
});
|
});
|
||||||
|
@ -503,7 +504,7 @@ module.exports = function(registry) {
|
||||||
define('__destroy__' + relationName, {
|
define('__destroy__' + relationName, {
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
http: {verb: 'delete', path: '/' + pathName},
|
http: {verb: 'delete', path: '/' + pathName},
|
||||||
description: g.f('Deletes %s of this model.', relationName),
|
description: format('Deletes %s of this model.', relationName),
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -517,10 +518,10 @@ module.exports = function(registry) {
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
http: {verb: 'get', path: '/' + pathName + '/:fk'},
|
http: {verb: 'get', path: '/' + pathName + '/:fk'},
|
||||||
accepts: {arg: 'fk', type: 'any',
|
accepts: {arg: 'fk', type: 'any',
|
||||||
description: g.f('Foreign key for %s', relationName),
|
description: format('Foreign key for %s', relationName),
|
||||||
required: true,
|
required: true,
|
||||||
http: {source: 'path'}},
|
http: {source: 'path'}},
|
||||||
description: g.f('Find a related item by id for %s.', relationName),
|
description: format('Find a related item by id for %s.', relationName),
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
returns: {arg: 'result', type: toModelName, root: true},
|
returns: {arg: 'result', type: toModelName, root: true},
|
||||||
rest: {after: convertNullToNotFoundError.bind(null, toModelName)}
|
rest: {after: convertNullToNotFoundError.bind(null, toModelName)}
|
||||||
|
@ -531,10 +532,10 @@ module.exports = function(registry) {
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
http: {verb: 'delete', path: '/' + pathName + '/:fk'},
|
http: {verb: 'delete', path: '/' + pathName + '/:fk'},
|
||||||
accepts: { arg: 'fk', type: 'any',
|
accepts: { arg: 'fk', type: 'any',
|
||||||
description: g.f('Foreign key for %s', relationName),
|
description: format('Foreign key for %s', relationName),
|
||||||
required: true,
|
required: true,
|
||||||
http: {source: 'path'}},
|
http: {source: 'path'}},
|
||||||
description: g.f('Delete a related item by id for %s.', relationName),
|
description: format('Delete a related item by id for %s.', relationName),
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
returns: []
|
returns: []
|
||||||
}, destroyByIdFunc);
|
}, destroyByIdFunc);
|
||||||
|
@ -545,12 +546,12 @@ module.exports = function(registry) {
|
||||||
http: {verb: 'put', path: '/' + pathName + '/:fk'},
|
http: {verb: 'put', path: '/' + pathName + '/:fk'},
|
||||||
accepts: [
|
accepts: [
|
||||||
{arg: 'fk', type: 'any',
|
{arg: 'fk', type: 'any',
|
||||||
description: g.f('Foreign key for %s', relationName),
|
description: format('Foreign key for %s', relationName),
|
||||||
required: true,
|
required: true,
|
||||||
http: { source: 'path' }},
|
http: { source: 'path' }},
|
||||||
{arg: 'data', type: toModelName, http: {source: 'body'}},
|
{arg: 'data', type: toModelName, http: {source: 'body'}},
|
||||||
],
|
],
|
||||||
description: g.f('Update a related item by id for %s.', relationName),
|
description: format('Update a related item by id for %s.', relationName),
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
returns: {arg: 'result', type: toModelName, root: true}
|
returns: {arg: 'result', type: toModelName, root: true}
|
||||||
}, updateByIdFunc);
|
}, updateByIdFunc);
|
||||||
|
@ -569,10 +570,10 @@ module.exports = function(registry) {
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
http: {verb: 'put', path: '/' + pathName + '/rel/:fk'},
|
http: {verb: 'put', path: '/' + pathName + '/rel/:fk'},
|
||||||
accepts: [{ arg: 'fk', type: 'any',
|
accepts: [{ arg: 'fk', type: 'any',
|
||||||
description: g.f('Foreign key for %s', relationName),
|
description: format('Foreign key for %s', relationName),
|
||||||
required: true,
|
required: true,
|
||||||
http: {source: 'path'}}].concat(accepts),
|
http: {source: 'path'}}].concat(accepts),
|
||||||
description: g.f('Add a related item by id for %s.', relationName),
|
description: format('Add a related item by id for %s.', relationName),
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
returns: {arg: relationName, type: modelThrough.modelName, root: true}
|
returns: {arg: relationName, type: modelThrough.modelName, root: true}
|
||||||
}, addFunc);
|
}, addFunc);
|
||||||
|
@ -582,10 +583,10 @@ module.exports = function(registry) {
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
http: {verb: 'delete', path: '/' + pathName + '/rel/:fk'},
|
http: {verb: 'delete', path: '/' + pathName + '/rel/:fk'},
|
||||||
accepts: {arg: 'fk', type: 'any',
|
accepts: {arg: 'fk', type: 'any',
|
||||||
description: g.f('Foreign key for %s', relationName),
|
description: format('Foreign key for %s', relationName),
|
||||||
required: true,
|
required: true,
|
||||||
http: {source: 'path'}},
|
http: {source: 'path'}},
|
||||||
description: g.f('Remove the %s relation to an item by id.', relationName),
|
description: format('Remove the %s relation to an item by id.', relationName),
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
returns: []
|
returns: []
|
||||||
}, removeFunc);
|
}, removeFunc);
|
||||||
|
@ -597,10 +598,10 @@ module.exports = function(registry) {
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
http: {verb: 'head', path: '/' + pathName + '/rel/:fk'},
|
http: {verb: 'head', path: '/' + pathName + '/rel/:fk'},
|
||||||
accepts: {arg: 'fk', type: 'any',
|
accepts: {arg: 'fk', type: 'any',
|
||||||
description: g.f('Foreign key for %s', relationName),
|
description: format('Foreign key for %s', relationName),
|
||||||
required: true,
|
required: true,
|
||||||
http: {source: 'path'}},
|
http: {source: 'path'}},
|
||||||
description: g.f('Check the existence of %s relation to an item by id.', relationName),
|
description: format('Check the existence of %s relation to an item by id.', relationName),
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
returns: {arg: 'exists', type: 'boolean', root: true},
|
returns: {arg: 'exists', type: 'boolean', root: true},
|
||||||
rest: {
|
rest: {
|
||||||
|
@ -643,7 +644,7 @@ module.exports = function(registry) {
|
||||||
isStatic: isStatic,
|
isStatic: isStatic,
|
||||||
http: {verb: 'get', path: '/' + pathName},
|
http: {verb: 'get', path: '/' + pathName},
|
||||||
accepts: {arg: 'filter', type: 'object'},
|
accepts: {arg: 'filter', type: 'object'},
|
||||||
description: g.f('Queries %s of %s.', scopeName, this.modelName),
|
description: format('Queries %s of %s.', scopeName, this.modelName),
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
returns: {arg: scopeName, type: [toModelName], root: true}
|
returns: {arg: scopeName, type: [toModelName], root: true}
|
||||||
});
|
});
|
||||||
|
@ -652,7 +653,7 @@ module.exports = function(registry) {
|
||||||
isStatic: isStatic,
|
isStatic: isStatic,
|
||||||
http: {verb: 'post', path: '/' + pathName},
|
http: {verb: 'post', path: '/' + pathName},
|
||||||
accepts: {arg: 'data', type: toModelName, http: {source: 'body'}},
|
accepts: {arg: 'data', type: toModelName, http: {source: 'body'}},
|
||||||
description: g.f('Creates a new instance in %s of this model.', scopeName),
|
description: format('Creates a new instance in %s of this model.', scopeName),
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
returns: {arg: 'data', type: toModelName, root: true}
|
returns: {arg: 'data', type: toModelName, root: true}
|
||||||
});
|
});
|
||||||
|
@ -660,7 +661,7 @@ module.exports = function(registry) {
|
||||||
define('__delete__' + scopeName, {
|
define('__delete__' + scopeName, {
|
||||||
isStatic: isStatic,
|
isStatic: isStatic,
|
||||||
http: {verb: 'delete', path: '/' + pathName},
|
http: {verb: 'delete', path: '/' + pathName},
|
||||||
description: g.f('Deletes all %s of this model.', scopeName),
|
description: format('Deletes all %s of this model.', scopeName),
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -668,8 +669,8 @@ module.exports = function(registry) {
|
||||||
isStatic: isStatic,
|
isStatic: isStatic,
|
||||||
http: {verb: 'get', path: '/' + pathName + '/count'},
|
http: {verb: 'get', path: '/' + pathName + '/count'},
|
||||||
accepts: {arg: 'where', type: 'object',
|
accepts: {arg: 'where', type: 'object',
|
||||||
description: g.f('Criteria to match model instances')},
|
description: 'Criteria to match model instances'},
|
||||||
description: g.f('Counts %s of %s.', scopeName, this.modelName),
|
description: format('Counts %s of %s.', scopeName, this.modelName),
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
returns: {arg: 'count', type: 'number'}
|
returns: {arg: 'count', type: 'number'}
|
||||||
});
|
});
|
||||||
|
@ -718,7 +719,7 @@ module.exports = function(registry) {
|
||||||
acceptArgs = [
|
acceptArgs = [
|
||||||
{
|
{
|
||||||
arg: paramName, type: 'any', http: { source: 'path' },
|
arg: paramName, type: 'any', http: { source: 'path' },
|
||||||
description: g.f('Foreign key for %s.', relation.name),
|
description: format('Foreign key for %s.', relation.name),
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -16,18 +16,6 @@ var debug = require('debug')('loopback:persisted-model');
|
||||||
var PassThrough = require('stream').PassThrough;
|
var PassThrough = require('stream').PassThrough;
|
||||||
var utils = require('./utils');
|
var utils = require('./utils');
|
||||||
|
|
||||||
// workaround for low performance of strong-globalize
|
|
||||||
// see https://github.com/strongloop/strong-globalize/issues/66
|
|
||||||
var stringCache = Object.create(null);
|
|
||||||
g.s = function(str) {
|
|
||||||
assert.equal(1, arguments.length, 'g.s() does not support parameters');
|
|
||||||
if (str in stringCache)
|
|
||||||
return stringCache[str];
|
|
||||||
var result = g.t(str);
|
|
||||||
stringCache[str] = result;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = function(registry) {
|
module.exports = function(registry) {
|
||||||
var Model = registry.getModel('Model');
|
var Model = registry.getModel('Model');
|
||||||
|
|
||||||
|
@ -627,7 +615,7 @@ module.exports = function(registry) {
|
||||||
}
|
}
|
||||||
|
|
||||||
setRemoting(PersistedModel, 'create', {
|
setRemoting(PersistedModel, 'create', {
|
||||||
description: g.s('Create a new instance of the model and persist it into the data source.'),
|
description: 'Create a new instance of the model and persist it into the data source.',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: {arg: 'data', type: 'object', description: 'Model instance data', http: {source: 'body'}},
|
accepts: {arg: 'data', type: 'object', description: 'Model instance data', http: {source: 'body'}},
|
||||||
returns: {arg: 'data', type: typeName, root: true},
|
returns: {arg: 'data', type: typeName, root: true},
|
||||||
|
@ -636,7 +624,7 @@ module.exports = function(registry) {
|
||||||
|
|
||||||
var upsertOptions = {
|
var upsertOptions = {
|
||||||
aliases: ['patchOrCreate', 'updateOrCreate'],
|
aliases: ['patchOrCreate', 'updateOrCreate'],
|
||||||
description: g.s('Patch an existing model instance or insert a new one into the data source.'),
|
description: 'Patch an existing model instance or insert a new one into the data source.',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: { arg: 'data', type: 'object', http: { source: 'body' }, description:
|
accepts: { arg: 'data', type: 'object', http: { source: 'body' }, description:
|
||||||
'Model instance data' },
|
'Model instance data' },
|
||||||
|
@ -665,7 +653,7 @@ module.exports = function(registry) {
|
||||||
setRemoting(PersistedModel, 'replaceOrCreate', replaceOrCreateOptions);
|
setRemoting(PersistedModel, 'replaceOrCreate', replaceOrCreateOptions);
|
||||||
|
|
||||||
setRemoting(PersistedModel, 'exists', {
|
setRemoting(PersistedModel, 'exists', {
|
||||||
description: g.s('Check whether a model instance exists in the data source.'),
|
description: 'Check whether a model instance exists in the data source.',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: {arg: 'id', type: 'any', description: 'Model id', required: true},
|
accepts: {arg: 'id', type: 'any', description: 'Model id', required: true},
|
||||||
returns: {arg: 'exists', type: 'boolean'},
|
returns: {arg: 'exists', type: 'boolean'},
|
||||||
|
@ -696,13 +684,13 @@ module.exports = function(registry) {
|
||||||
});
|
});
|
||||||
|
|
||||||
setRemoting(PersistedModel, 'findById', {
|
setRemoting(PersistedModel, 'findById', {
|
||||||
description: g.s('Find a model instance by {{id}} from the data source.'),
|
description: 'Find a model instance by {{id}} from the data source.',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: [
|
accepts: [
|
||||||
{ arg: 'id', type: 'any', description: 'Model id', required: true,
|
{ arg: 'id', type: 'any', description: 'Model id', required: true,
|
||||||
http: {source: 'path'}},
|
http: {source: 'path'}},
|
||||||
{ arg: 'filter', type: 'object',
|
{ arg: 'filter', type: 'object',
|
||||||
description: g.s('Filter defining fields and include') },
|
description: 'Filter defining fields and include' },
|
||||||
],
|
],
|
||||||
returns: {arg: 'data', type: typeName, root: true},
|
returns: {arg: 'data', type: typeName, root: true},
|
||||||
http: {verb: 'get', path: '/:id'},
|
http: {verb: 'get', path: '/:id'},
|
||||||
|
@ -729,7 +717,7 @@ module.exports = function(registry) {
|
||||||
setRemoting(PersistedModel, 'replaceById', replaceByIdOptions);
|
setRemoting(PersistedModel, 'replaceById', replaceByIdOptions);
|
||||||
|
|
||||||
setRemoting(PersistedModel, 'find', {
|
setRemoting(PersistedModel, 'find', {
|
||||||
description: g.s('Find all instances of the model matched by filter from the data source.'),
|
description: 'Find all instances of the model matched by filter from the data source.',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: {arg: 'filter', type: 'object', description: 'Filter defining fields, where, include, order, offset, and limit'},
|
accepts: {arg: 'filter', type: 'object', description: 'Filter defining fields, where, include, order, offset, and limit'},
|
||||||
returns: {arg: 'data', type: [typeName], root: true},
|
returns: {arg: 'data', type: [typeName], root: true},
|
||||||
|
@ -737,7 +725,7 @@ module.exports = function(registry) {
|
||||||
});
|
});
|
||||||
|
|
||||||
setRemoting(PersistedModel, 'findOne', {
|
setRemoting(PersistedModel, 'findOne', {
|
||||||
description: g.s('Find first instance of the model matched by filter from the data source.'),
|
description: 'Find first instance of the model matched by filter from the data source.',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: {arg: 'filter', type: 'object', description: 'Filter defining fields, where, include, order, offset, and limit'},
|
accepts: {arg: 'filter', type: 'object', description: 'Filter defining fields, where, include, order, offset, and limit'},
|
||||||
returns: {arg: 'data', type: typeName, root: true},
|
returns: {arg: 'data', type: typeName, root: true},
|
||||||
|
@ -746,7 +734,7 @@ module.exports = function(registry) {
|
||||||
});
|
});
|
||||||
|
|
||||||
setRemoting(PersistedModel, 'destroyAll', {
|
setRemoting(PersistedModel, 'destroyAll', {
|
||||||
description: g.s('Delete all matching records.'),
|
description: 'Delete all matching records.',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: {arg: 'where', type: 'object', description: 'filter.where object'},
|
accepts: {arg: 'where', type: 'object', description: 'filter.where object'},
|
||||||
returns: {
|
returns: {
|
||||||
|
@ -761,17 +749,17 @@ module.exports = function(registry) {
|
||||||
|
|
||||||
setRemoting(PersistedModel, 'updateAll', {
|
setRemoting(PersistedModel, 'updateAll', {
|
||||||
aliases: ['update'],
|
aliases: ['update'],
|
||||||
description: g.s('Update instances of the model matched by {{where}} from the data source.'),
|
description: 'Update instances of the model matched by {{where}} from the data source.',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: [
|
accepts: [
|
||||||
{arg: 'where', type: 'object', http: { source: 'query'},
|
{arg: 'where', type: 'object', http: { source: 'query'},
|
||||||
description: g.s('Criteria to match model instances')},
|
description: 'Criteria to match model instances'},
|
||||||
{arg: 'data', type: 'object', http: {source: 'body'},
|
{arg: 'data', type: 'object', http: {source: 'body'},
|
||||||
description: g.s('An object of model property name/value pairs')},
|
description: 'An object of model property name/value pairs'},
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
arg: 'count',
|
arg: 'count',
|
||||||
description: g.s('The number of instances updated'),
|
description: 'The number of instances updated',
|
||||||
type: 'object',
|
type: 'object',
|
||||||
root: true
|
root: true
|
||||||
},
|
},
|
||||||
|
@ -780,7 +768,7 @@ module.exports = function(registry) {
|
||||||
|
|
||||||
setRemoting(PersistedModel, 'deleteById', {
|
setRemoting(PersistedModel, 'deleteById', {
|
||||||
aliases: ['destroyById', 'removeById'],
|
aliases: ['destroyById', 'removeById'],
|
||||||
description: g.s('Delete a model instance by {{id}} from the data source.'),
|
description: 'Delete a model instance by {{id}} from the data source.',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: {arg: 'id', type: 'any', description: 'Model id', required: true,
|
accepts: {arg: 'id', type: 'any', description: 'Model id', required: true,
|
||||||
http: {source: 'path'}},
|
http: {source: 'path'}},
|
||||||
|
@ -789,7 +777,7 @@ module.exports = function(registry) {
|
||||||
});
|
});
|
||||||
|
|
||||||
setRemoting(PersistedModel, 'count', {
|
setRemoting(PersistedModel, 'count', {
|
||||||
description: g.s('Count instances of the model matched by where from the data source.'),
|
description: 'Count instances of the model matched by where from the data source.',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: {arg: 'where', type: 'object', description: 'Criteria to match model instances'},
|
accepts: {arg: 'where', type: 'object', description: 'Criteria to match model instances'},
|
||||||
returns: {arg: 'count', type: 'number'},
|
returns: {arg: 'count', type: 'number'},
|
||||||
|
@ -798,7 +786,7 @@ module.exports = function(registry) {
|
||||||
|
|
||||||
var updateAttributesOptions = {
|
var updateAttributesOptions = {
|
||||||
aliases: ['patchAttributes'],
|
aliases: ['patchAttributes'],
|
||||||
description: g.s('Patch attributes for a model instance and persist it into the data source.'),
|
description: 'Patch attributes for a model instance and persist it into the data source.',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
|
|
||||||
accepts: { arg: 'data', type: 'object', http: { source: 'body' }, description: 'An object of model property name/value pairs' },
|
accepts: { arg: 'data', type: 'object', http: { source: 'body' }, description: 'An object of model property name/value pairs' },
|
||||||
|
@ -814,7 +802,7 @@ module.exports = function(registry) {
|
||||||
|
|
||||||
if (options.trackChanges || options.enableRemoteReplication) {
|
if (options.trackChanges || options.enableRemoteReplication) {
|
||||||
setRemoting(PersistedModel, 'diff', {
|
setRemoting(PersistedModel, 'diff', {
|
||||||
description: g.s('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'},
|
||||||
|
@ -826,8 +814,8 @@ module.exports = function(registry) {
|
||||||
});
|
});
|
||||||
|
|
||||||
setRemoting(PersistedModel, 'changes', {
|
setRemoting(PersistedModel, 'changes', {
|
||||||
description: g.s('Get the changes to a model since a given checkpoint.' +
|
description: 'Get the changes to a model since a given checkpoint.' +
|
||||||
'Provide a filter object to reduce the number of results returned.'),
|
'Provide a filter object to reduce the number of results returned.',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: [
|
accepts: [
|
||||||
{arg: 'since', type: 'number', description: 'Only return changes since this checkpoint'},
|
{arg: 'since', type: 'number', description: 'Only return changes since this checkpoint'},
|
||||||
|
@ -838,7 +826,7 @@ module.exports = function(registry) {
|
||||||
});
|
});
|
||||||
|
|
||||||
setRemoting(PersistedModel, 'checkpoint', {
|
setRemoting(PersistedModel, 'checkpoint', {
|
||||||
description: g.s('Create a checkpoint.'),
|
description: 'Create a checkpoint.',
|
||||||
// The replication algorithm needs to create a source checkpoint,
|
// The replication algorithm needs to create a source checkpoint,
|
||||||
// even though it is otherwise not making any source changes.
|
// even though it is otherwise not making any source changes.
|
||||||
// We need to allow this method for users that don't have full
|
// We need to allow this method for users that don't have full
|
||||||
|
@ -849,14 +837,14 @@ module.exports = function(registry) {
|
||||||
});
|
});
|
||||||
|
|
||||||
setRemoting(PersistedModel, 'currentCheckpoint', {
|
setRemoting(PersistedModel, 'currentCheckpoint', {
|
||||||
description: g.s('Get the current checkpoint.'),
|
description: 'Get the current checkpoint.',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
returns: {arg: 'checkpoint', type: 'object', root: true},
|
returns: {arg: 'checkpoint', type: 'object', root: true},
|
||||||
http: {verb: 'get', path: '/checkpoint'}
|
http: {verb: 'get', path: '/checkpoint'}
|
||||||
});
|
});
|
||||||
|
|
||||||
setRemoting(PersistedModel, 'createUpdates', {
|
setRemoting(PersistedModel, 'createUpdates', {
|
||||||
description: g.s('Create an update list from a delta list.'),
|
description: 'Create an update list from a delta list.',
|
||||||
// This operation is read-only, it does not change any local data.
|
// This operation is read-only, it does not change any local data.
|
||||||
// It is called by the replication algorithm to compile a list
|
// It is called by the replication algorithm to compile a list
|
||||||
// of changes to apply on the target.
|
// of changes to apply on the target.
|
||||||
|
@ -867,14 +855,14 @@ module.exports = function(registry) {
|
||||||
});
|
});
|
||||||
|
|
||||||
setRemoting(PersistedModel, 'bulkUpdate', {
|
setRemoting(PersistedModel, 'bulkUpdate', {
|
||||||
description: g.s('Run multiple updates at once. Note: this is not atomic.'),
|
description: 'Run multiple updates at once. Note: this is not atomic.',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: {arg: 'updates', type: 'array'},
|
accepts: {arg: 'updates', type: 'array'},
|
||||||
http: {verb: 'post', path: '/bulk-update'}
|
http: {verb: 'post', path: '/bulk-update'}
|
||||||
});
|
});
|
||||||
|
|
||||||
setRemoting(PersistedModel, 'findLastChange', {
|
setRemoting(PersistedModel, 'findLastChange', {
|
||||||
description: g.s('Get the most recent change record for this instance.'),
|
description: 'Get the most recent change record for this instance.',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
accepts: {
|
accepts: {
|
||||||
arg: 'id', type: 'any', required: true, http: { source: 'path' },
|
arg: 'id', type: 'any', required: true, http: { source: 'path' },
|
||||||
|
@ -885,10 +873,9 @@ module.exports = function(registry) {
|
||||||
});
|
});
|
||||||
|
|
||||||
setRemoting(PersistedModel, 'updateLastChange', {
|
setRemoting(PersistedModel, 'updateLastChange', {
|
||||||
description: [
|
description:
|
||||||
g.s('Update the properties of the most recent change record ' +
|
'Update the properties of the most recent change record ' +
|
||||||
'kept for this instance.'),
|
'kept for this instance.',
|
||||||
],
|
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: [
|
accepts: [
|
||||||
{
|
{
|
||||||
|
@ -897,7 +884,7 @@ module.exports = function(registry) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
arg: 'data', type: 'object', http: {source: 'body'},
|
arg: 'data', type: 'object', http: {source: 'body'},
|
||||||
description: g.s('An object of Change property name/value pairs'),
|
description: 'An object of Change property name/value pairs',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
returns: { arg: 'result', type: this.Change.modelName, root: true },
|
returns: { arg: 'result', type: this.Change.modelName, root: true },
|
||||||
|
@ -923,7 +910,7 @@ module.exports = function(registry) {
|
||||||
}
|
}
|
||||||
|
|
||||||
setRemoting(PersistedModel, 'createChangeStream', {
|
setRemoting(PersistedModel, 'createChangeStream', {
|
||||||
description: g.s('Create a change stream.'),
|
description: 'Create a change stream.',
|
||||||
accessType: 'READ',
|
accessType: 'READ',
|
||||||
http: [
|
http: [
|
||||||
{verb: 'post', path: '/change-stream'},
|
{verb: 'post', path: '/change-stream'},
|
||||||
|
|
Loading…
Reference in New Issue