Start a new topic

How to i fetch a entire specific column from my collection. IOS

Hi I had a question. How to i fetch a entire specific column from my collection.

1 person has this question

Good morning Harish, Unfortunately there is no "easy" way to do this with MongoDB. Thanks,

Is it still (3 years later) still a fact (based by concept) that I always will get all columns of a collection on querying it?


Example in RDB:

SELECT a, b, c FROM table;

-> Returns values from columns a, b, c


SELECT a FROM table;

-> Returns only values from column a


So there is no similar option using MongoDB? Just considering to reduce traffic by querying what I really need at that time.


Tayger,


Yes. When you are querying a datastore, you will always get the complete entity rows which are matching the query in the JSON format i.e. it will contain all the columns available for that entity row/ record.



Thanks,

Pranav

Kinvey

Tayger,


While reviewing Kinvey's REST API guide, I found there is a modifier called "fields" which is used to only return a certain set of properties from matching entities. Check this link. Please ignore my earlier comment since use of 'fields' went unnoticed as the SDK guide doesn't mention it. While using iOS SDK, you would pass this as Query fields, and specify the fields you want to be returned. Check this link for the details. Certain fields that are essential to each entity will always be returned e.g. _id, _acl and _kmd


Thanks,

Pranav


While doing some researches I have found them too and tried them out yesterday - work smoothly! It's no problem to get some other additional default values back just no "big" JSON documents. ;)

Login or Signup to post a comment