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
whitecolor opened this Issue Oct 16, 2013 · 4 comments

Comments

Projects
None yet
3 participants
@whitecolor
Contributor

whitecolor 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

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Oct 16, 2013

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

Contributor

justinbmeyer commented Oct 16, 2013

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

@whitecolor

This comment has been minimized.

Show comment
Hide comment
@whitecolor

whitecolor Oct 16, 2013

Contributor

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

Contributor

whitecolor 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

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Oct 16, 2013

Contributor

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

Contributor

justinbmeyer commented Oct 16, 2013

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

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer May 3, 2014

Contributor

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

@property {String} can.Model.resource 

It doesn't return anything.

Contributor

justinbmeyer commented May 3, 2014

@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