Support relation by foreign id #62

Closed
wants to merge 7 commits into
from

Conversation

Projects
None yet
2 participants

xslim commented Oct 8, 2012

Currently relations are supported by searching relationName in representation

This hack allows building relations by using relationName_id or relationName_ids, as many Ruby on Rails engines return.

Contributor

mattt commented Oct 11, 2012

Thanks for your pull request, @xslim. There's a lot in here other than the foreign ID stuff, so it's going to take some time for me to determine what I should take from this. Bear with me for a moment.

xslim commented Oct 11, 2012

Sorry for a lot of commits, I'm trying to use the library in current app development, and I stuccoed with the problem of entities are not saved in DB. So some of the commits are fixing this issue.

xslim commented Oct 11, 2012

Also I've made implementation for sending If-Modified-Since and working with 304 Not Modified… but this work is currently in my gist https://gist.github.com/3855430

If you have any comments how to improve the code for pull request - please tell me I'll do that.

Contributor

mattt commented Oct 11, 2012

No worries at all—thanks for your contributions.

As it were, I just added Last-Modified support myself, with 40bee2d. It takes a different approach from yours by managing Last-Modified in the same way as resource identifiers. Interested to hear any thoughts you have.

xslim commented Oct 11, 2012

You developed Last-Modified for "per-resource request"

What I did in my gist, is developed Last-modified when requesting "array" of items.

The example implementation on rails side is

#AreasController
  def index
    @areas = parent.areas
    if stale?(last_modified: @areas.max(:updated_at))
      respond_with @areas
    end
  end

So I get the last modified area in database, and send this info to server. Server checks it against his DB and returns just :304 if nothing changed, or :200 with the list of areas if there were changes. This saves bandwidth.

xslim commented Oct 11, 2012

https://github.com/xslim/AFIncrementalStore/commit/06041256e5c76190fba714f4b6d8a4c2aff8c180 prevents crashing when server sends 304 Not-Modified and empty data in success.

To make 304 a success response I also added this code in APIClient subclass

// 304 Not-Modified
[AFJSONRequestOperation addAcceptableStatusCodes:[NSIndexSet indexSetWithIndex:304]];

xslim commented Oct 12, 2012

Should I change my pull request to reflect your latest commits?

Contributor

mattt commented Nov 18, 2014

As of e8c6472, AFIncrementalStore is no longer being actively maintained. Thank you for your contributions; my sincere apologies for any inconvenience this may have caused.

@mattt mattt closed this Nov 18, 2014

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