From c2b233015ad6a39a17ce0c7a3564e503b92c06d5 Mon Sep 17 00:00:00 2001 From: Adam Hong Date: Tue, 9 Feb 2021 16:44:39 -0800 Subject: [PATCH] fix: numerical IDs --- lib/model.js | 2 +- lib/persisted-model.js | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/model.js b/lib/model.js index 61fe5c3f..bcb9db08 100644 --- a/lib/model.js +++ b/lib/model.js @@ -185,7 +185,7 @@ module.exports = function(registry) { var idDesc = ModelCtor.modelName + ' id'; ModelCtor.sharedCtor.accepts = [ - {arg: 'id', type: 'any', required: true, http: {source: 'path'}, + {arg: 'id', type: 'string', required: true, http: {source: 'path'}, description: idDesc} // {arg: 'instance', type: 'object', http: {source: 'body'}} ]; diff --git a/lib/persisted-model.js b/lib/persisted-model.js index 3e4530e6..3ed3c737 100644 --- a/lib/persisted-model.js +++ b/lib/persisted-model.js @@ -692,7 +692,7 @@ module.exports = function(registry) { setRemoting(PersistedModel, 'exists', { description: 'Check whether a model instance exists in the data source.', accessType: 'READ', - accepts: {arg: 'id', type: 'any', description: 'Model id', required: true}, + accepts: {arg: 'id', type: 'string', description: 'Model id', required: true}, returns: {arg: 'exists', type: 'boolean'}, http: [ {verb: 'get', path: '/:id/exists'}, @@ -724,7 +724,7 @@ module.exports = function(registry) { description: 'Find a model instance by {{id}} from the data source.', accessType: 'READ', accepts: [ - { arg: 'id', type: 'any', description: 'Model id', required: true, + { arg: 'id', type: 'string', description: 'Model id', required: true, http: {source: 'path'}}, { arg: 'filter', type: 'object', description: 'Filter defining fields and include' }, @@ -738,7 +738,7 @@ module.exports = function(registry) { description: 'Replace attributes for a model instance and persist it into the data source.', accessType: 'WRITE', accepts: [ - { arg: 'id', type: 'any', description: 'Model id', required: true, + { arg: 'id', type: 'string', description: 'Model id', required: true, http: { source: 'path' }}, { arg: 'data', type: 'object', model: typeName, http: { source: 'body' }, description: 'Model instance data' }, @@ -807,7 +807,7 @@ module.exports = function(registry) { aliases: ['destroyById', 'removeById'], description: 'Delete a model instance by {{id}} from the data source.', accessType: 'WRITE', - accepts: {arg: 'id', type: 'any', description: 'Model id', required: true, + accepts: {arg: 'id', type: 'string', description: 'Model id', required: true, http: {source: 'path'}}, http: {verb: 'del', path: '/:id'}, returns: {arg: 'count', type: 'object', root: true} @@ -906,7 +906,7 @@ module.exports = function(registry) { description: 'Get the most recent change record for this instance.', accessType: 'READ', accepts: { - arg: 'id', type: 'any', required: true, http: { source: 'path' }, + arg: 'id', type: 'string', required: true, http: { source: 'path' }, description: 'Model id' }, returns: { arg: 'result', type: this.Change.modelName, root: true }, @@ -920,7 +920,7 @@ module.exports = function(registry) { accessType: 'WRITE', accepts: [ { - arg: 'id', type: 'any', required: true, http: { source: 'path' }, + arg: 'id', type: 'string', required: true, http: { source: 'path' }, description: 'Model id' }, { @@ -945,7 +945,7 @@ module.exports = function(registry) { setRemoting(PersistedModel, 'rectifyChange', { description: 'Tell loopback that a change to the model with the given id has occurred.', accessType: 'WRITE', - accepts: {arg: 'id', type: 'any', http: {source: 'path'}}, + accepts: {arg: 'id', type: 'string', http: {source: 'path'}}, http: {verb: 'post', path: '/:id/rectify-change'} }); }