You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
id field always named id in generated resources, event for non-standard id names #89
My Member model id field is actually named username, which makes this confusing because sometimes id must be used and some other time username (when it's not an angular resource expected id field)
Note : additionally, the above resources is used by calling Member.findById({id: xxx}), what about wrapping that in a more isomorphic findById that would only take the id as argument like on the server : Member.findById(xxx) ?
My Member model id field is actually named username, which makes this confusing because sometimes id must be used and some other time username (when it's not an angular resource expected id field)
Does the REST API work for you when the id property is not named :id? AFAIK, constructor's REST route is always /:id. I am not sure if this :id parameter is internally converted to :username, I would expect it is not.
What I find interesting: my assumption was that front-end devs would prefer the consistency of using id everywhere, as opposed to consistent id property name between the client and the server.
Note : additionally, the above resources is used by calling Member.findById({id: xxx}), what about wrapping that in a more isomorphic findById that would only take the id as argument like on the server : Member.findById(xxx) ?
So far the generated Model resources were conforming to ngResource API. While the ngResource module has many problems, it is at least a part of Angular, thus Angular devs should be familiar with it. There are also things like request/response interceptors that we have for free now.
Your proposal would move the SDK away from ngResource API towards an isomorphic API. It's an interesting idea. It makes me wonder if we can come up with an API that would be close to what is proposed in #83, thus splitting the whole transition into multiple smaller steps.
Unfortunately the Angular SDK is not a high priority for us now, I won't have time to implement these changes myself. And as you can see, I don't have enough time to guide you through big pull requests like #84 either :(
To keep this actionable: if you don't mind slow pace of progress, we can discuss incremental steps how to change the codegen to produce the new API. Alternatively, you can create an alternate/unofficial SDK code generator in your own repo and do all the work there, without waiting for my review/approval.
What I find interesting: my assumption was that front-end devs would prefer the consistency of using id everywhere, as opposed to consistent id property name between the client and the server.
Actually, only the REST route variable is named 'id', the object themselves use the configured id property name, hence username : the data is returned to the client with username, and the same is used in angular to access the value, etc.
So even for a pure angular developper dealing with client-side-only code, he will have to call p = Profile.findById({id: xx}) but then use p.username to access the value on the resulting object.
For the integration of my contributed code, nevermind if you don't have time, I try to keep in sync with the main repo by rebasing my branch every now and then.
I also agree with your point on sticking to ngResource/angular way of things
Activity
bajtos commentedon Oct 23, 2014
Does the REST API work for you when the
idproperty is not named:id? AFAIK, constructor's REST route is always/:id. I am not sure if this:idparameter is internally converted to:username, I would expect it is not.Related discussion: strongloop/loopback#126
What I find interesting: my assumption was that front-end devs would prefer the consistency of using
ideverywhere, as opposed to consistent id property name between the client and the server.So far the generated Model resources were conforming to
ngResourceAPI. While the ngResource module has many problems, it is at least a part of Angular, thus Angular devs should be familiar with it. There are also things like request/response interceptors that we have for free now.Your proposal would move the SDK away from ngResource API towards an isomorphic API. It's an interesting idea. It makes me wonder if we can come up with an API that would be close to what is proposed in #83, thus splitting the whole transition into multiple smaller steps.
Unfortunately the Angular SDK is not a high priority for us now, I won't have time to implement these changes myself. And as you can see, I don't have enough time to guide you through big pull requests like #84 either :(
To keep this actionable: if you don't mind slow pace of progress, we can discuss incremental steps how to change the codegen to produce the new API. Alternatively, you can create an alternate/unofficial SDK code generator in your own repo and do all the work there, without waiting for my review/approval.
pandaiolo commentedon Oct 23, 2014
Actually, only the REST route variable is named 'id', the object themselves use the configured id property name, hence
username: the data is returned to the client withusername, and the same is used in angular to access the value, etc.So even for a pure angular developper dealing with client-side-only code, he will have to call
p = Profile.findById({id: xx})but then usep.usernameto access the value on the resulting object.For the integration of my contributed code, nevermind if you don't have time, I try to keep in sync with the main repo by rebasing my branch every now and then.
I also agree with your point on sticking to ngResource/angular way of things
bajtos commentedon Apr 19, 2018
Looks like the discussion ended more than three years ago, I am closing the issue.