Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can.Model: one URL property for REST resource #501

Closed
wclr opened this issue Oct 16, 2013 · 4 comments
Closed

can.Model: one URL property for REST resource #501

wclr opened this issue Oct 16, 2013 · 4 comments

Comments

@wclr
Copy link
Contributor

wclr commented Oct 16, 2013

The old question. For can.Model why not make one property

resource: '/api/v1/items'

that would save one from the following code:

findAll: 'GET /api/v1/items',
findOne: 'GET /api/v1/items/{id}',
create: 'POST /api/v1/items',
update: 'PUT /api/v1/items/{id}',
destroy: 'DEL /api/v1/items/{id}'

VOTE FOR THIS HERE: http://bithub.com/event/25881

@justinbmeyer
Copy link
Contributor

For me, it just hasn't been an itch I've needed to scratch.

You could do something like:

resourcify = function(url, static){
  return can.extend({
    findAll: url,
    findOne: url+"/{id}",
    ...
  }, static || {})
}
MyModel = can.Model.extend(resourcify("/api/v1/items"),{})

without it being backed in

@wclr
Copy link
Contributor Author

wclr commented Oct 16, 2013

Yes, thanks, I though maybe it would be convenient to build it in, it is not big itch for me too though.

@justinbmeyer
Copy link
Contributor

If we saw a pull request that documented it well, and didn't add much code, I'd accept it. Thanks!

@justinbmeyer
Copy link
Contributor

@mjstahl This should be a property, not a function, like:

@property {String} can.Model.resource 

It doesn't return anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants