Improve remoting metadata: register exported models using singular names - #151
Conversation
|
Related changes: loopbackio/loopback-datasource-juggler#60 and strongloop/strong-remoting#37 |
|
Any way this can be backwards compatible? 2.0 will make it hard for people to get fixes. |
Set the HTTP route to `'/' + pluralModelName` so that we don't have to duplicate this bit of logic in strong-remoting and other places.
|
Test PASSed. To trigger a build add comment - ".test\W+please" |
I will try to come up with some kind of a compatibility layer tomorrow. The difficult part is how to avoid duplicate entries. Perhaps strong-remoting could support some sort of alias for class names. On the other hand, the parts affected by this change are sort of internal and not documented well (if at all), which means the number of affected users should be very small. I guess could post a question on our mailing list to find out if there is anybody using these features. I will probably make the compatibility layer turned off by default. The idea is to make sure there is a quick solution if somebody needs it, but don't let new users use the legacy APIs. |
|
Test PASSed. To trigger a build add comment - ".test\W+please" |
|
@ritch I have added another commit that introduces The idea is that after our user upgrades from v1.x to v2.x and finds out that his application no longer works, s/he can add one line to his app.js file to get the good old behaviour: // app.js
loopback.compat.usePluralNamesForRemoting = true;This way they can use the new features & bugfixes from 2.x versions without having to immediately rewrite their application. Maybe we can release this change as v1.6 instead of v2.0? As I wrote earlier, I don't expect there will be many people affected by this change (if any at all). |
|
Test PASSed. To trigger a build add comment - ".test\W+please" |
|
As I was implementing the Angular code generator, I realised it's possible to find the singular model name somewhere deep in the metadata object tree. So this pull request is not strictly necessary. This is the question we should consider: Are we happy with the inconsistent class names (singular in LoopBack and app, plural in strong-remoting)? I am not, but you may have a different opinion. If we agree that the class names should be consistent, then it's best to make the change now, until the number of affected users is low. If we don't mind the inconsistency, then this pull request can be closed and I'll implement a workaround in the code gen. /to: @ritch @raymondfeng |
|
+1 for consistency |
|
+1 for consistency too. Otherwise, the changes LGTM. |
|
+1 for consistency. this is the kind of thing can really come back to haunt On Fri, Jan 24, 2014 at 8:21 AM, Raymond Feng notifications@github.comwrote:
|
|
merge it 👍 |
|
Note: we should release this as |
|
No qualms here. |
Use the new property introduced by a recent change in loopback-datasource-juggler instead of building the URL manually from pluralModelName.
Remove the inconsistency between model names used by LoopBack app and datasource-juggler (modelName, e.g. User) and the name used by strong-remoting (pluralModelName, e.g. Users). This way the class name in the strong-remoting metadata can be used by client-code generators. Before this change, the generators would produce method names like `Users.login`.
Add a compatibility layer that allows applications based on LB pre-v1.6 to work with 1.6 versions with a minimum amount of changes required. New flag(s): compat.usePluralNamesForRemoting
strong-remoting ~1.2.1 loopback-datasource-juggler ~1.2.13
…data Improve remoting metadata: register exported models using singular names
The first commit is just a cleanup that was made possible by strongloop/strong-remoting#37.
The second change is the purpose of this pull request:
Important note
This patch is introducing several incompatibilities with previous versions:
app.remotes().exportswill no longer work.app.remoteObjects()uses singular names for the keys. Any code expecting plural keys will no longer work.ModelClass.beforeRemote/afterRemoteand registering hooks direcly viaapp.remotes().before/afterwill no longer works.Code using the keys of
app.remotes().exportsorapp.remoteObjects()to build remotable method names (e.g.key + '.create'will continue to work./to: @ritch or @raymondfeng please review
To follow semver rules, we should release this change as LoopBack 2.0. Any objections?