We are trying to build a simple follow feature for our IOS app. We have two API’s our Brand API
with an array of objects containing unique brand ids for our brands within each object. And our Firebase API
where we store users. Within the Firebase API
it has a key called followingBrands with and array of objects called composed of the unique brand ids from our
Brand API` as keys with the value true. The objects are created once a user has followed the brand from liking the brand on our app.
When the app loads we check to see if Firebase API
‘s brand ids keys matches the Brand API
‘s brand ID then show a star to indicate the user is already following the brand.
Our problem is Brand API
is implemented with pagination, (i.e. offset), so how will we verify all brands they are following if not all the unique brand ids will be available to compare with our Firebase API
?
We use swift on the IOS side. And the Brand API
is built using django-tastypie
Firebase API
"user_id" : {
"currentFollowingCount" : 0,
"displayName" : "",
"email" : "",
"followingBrands" : {
"unique_brand_id" : true
},
"provider" : "Facebook",
"userID" : "user_id"
}
Brand API
{
"labels": [
{
"id": "unique_brand_id"
}
],
"meta": {
"limit": 10,
"next": "/api/?limit=10&offset=10",
"offset": 0,
"previous": null,
"total_count": 33
}
}
2
Answers
It’s not really clear what you’re trying to accomplish to be honest. The Brand API doesn’t do a lot, or? Or is it translating between internal ID’s and unique brand ID’s? If so, why?
As a simple problem solution you could turn off pagination, according to your output of tastypie there are only 33 records in your set, so setting a limit either via the
Meta
class, e.g.max_limit = 1000
or when calling the API resource via?limit=1000
should return all objects. If they don’t change much you should probably apply some caching.you can do a trick just show the star whenever there is a brandID equals to you fireBase followingBrands key. you don’t need to check it in brandAPI as i think you already insert every brand followed by user in the fireBaseAPi so this will work for you.