How to prepare array by making two API calls - ios

I'm making an "API" call for getting a list of "MyMusic" album. It returns array of music ids and those ids are linked with another table. So in order to get music details like name etc. I need to make separate "API" calls with id.
What is the recommended way to make "API" calls to fill my array with music details.

Depends on if the API can return multiple id's. Can you send a JSON-array to the API and get an array in return? If not, it looks like you have to send the id's one at a time.

If you don't for some reason NEED to use the REST api (which it seems you are doing now), then in your first query use includeKey on the field that contains the IDs. If this field is a Pointer to another table, this will make sure the full objects are returned in the first query instead of just the pointers.

Related

ADF - Odata - How to perform an optional select

I've created an ADF flow that loops over URL's to fetch OData using the OData connection.
However, not all fields are available in all URL's, there are certain ones that are available in one URL, but not in the other. A $Select is used to select the fields that we need.
Is it possible to have an optional selection (as in, if the path is not available, do not fetch this field and return null instead for instance)? Would help us a great deal.
I've tried adding ? after the field, but that does not work. $select=Field1,Field2,FieldOptional?
Thanks
As I understand you are trying to loop through a bunch of a URL and the query on the ODATA URL will change and so will be the fields . I think you can use a lookup where you pass the unique url and its gives the fields and then concatenate the url with the fields and make a odata call .

iOS: Modeling Friends List with Syncano DB

I'm trying to get a handle on how to use custom Swift classes to model my Syncano backend. I have classes MPUser and MPUserProfile exactly as described in this guide. However, instead of adding an avatar field, I'd like to add a friends list. Should this property be:
An array of MPUsers
An array of MPUserProfiles
An array of integers corresponding to the other users' IDs
Something else?
Edit: their page on classes makes it sounds like I would want an array of type Reference (referring to users' IDs) but their arrays can only have string/int/boolean/float. I'm now wondering if an array of (non-Reference) integers will work fine.
Thank you for your help.
Currently Syncano doesn't support holding arrays of references. It's something we are working on (adding many-to-many relationships), but in the meantime you should could safely just use array type and store ID of referenced objects in there.
When you store array of IDs, you can use either ID of a user, or ID of a user profile.
The connection between them is as follows:
User is a physical user that logs into your app.
His profile is an object that belongs to him.
User A cannot be accessed by user B, but profile of user A can be accessed by user B.
You can get a profile of user A either by using profile ID (object id from user_profile class), or by using user A id (owner field in object inside user_profile class).
Depending on which route you take, you can then ask Syncano for list of all friends doing either:
give me all user profiles, where ID is in [array of user profile IDs]
or, give me all user profile, where owner is in [array of user IDs]
An array of MPUser's definitely. I haven't used Syncano so I may be utterly wrong on this, but having using Couch, Firebase and played with Realm...
The whole idea of key/value/object/document stores like these is that details of the storage are abstracted away in the back end. So you put an MPUser in an array, and when you access that array sometime later you get it back. Totally magic. That the DB itself might physically store that as an Int64 or inline the entire string is of no interest to you - data in, data out.
I suspect you have worked in the SQL world, which is why you put that last option there? Generally that's not how you work in object stores - thank gawd.

How to get all data back in an ios parse query

I have two tables each with one record(for testing and question purposes). These tables are Post and Comment. Post has a PFRelation called myComment (I know only one comment - lets call it a feature for now). If I query Post, how do I get the Post and Comment data back?
Can't find this anywhere using web search engines or Parse docs (not a complete answer at least).
Because Relation in Parse is just like its literal meaning, it does not contain any data. If you want to get the data back, you need to get that instance of Relation first. Then call query from that instance. After that, you just perform that query if you want to get all objects from this Relation. You can also add some constraints after getting the query from Relation.
If you use Pointer type, you can just get back the data by using includeKey:.

APIs not returning custom field

for our scopes we need to use unique ID generated by us for the answers submitted by users. This is possible by adding "?c=" at the end of the survey link followed by the ID number.
Example Format: http://www.surveymonkey.com/s/XXXXX?c=00001
The terrific problem is that the custom value is not returned anyway via API. It is not added as a property of the Answer object neither its value replaces somehow the respondant_id property.
We see that you are able to expose that data from your internal endpoints that you use for your proprietary web interface but how to get this data from he outside via API?
Thanks
When you call 'get_respondent_list', ensure you pass through 'custom_id' in the list of strings in the 'fields' parameter. This will then be returned in the output with the custom value you entered.

OData: last insert ID equivalent

We're currently interfacing with an OData database, over HTTP.
I need to POST objects (i.e. create them). This works, but how can I get the identifier of the created object?
Comparing this to SQL, how could I get the last insert ID?
OData posts responses contain the object that was created. So, you should be able to parse the response and find out the key(ID). The $metadata document would tell you which properties are the keys.

Resources