Page 1 of 1

How do I use the include parameter in a query and pull out only selected columns from a pointer ?

Posted: Thu Jan 15, 2015 2:27 pm
by Shawn

I have a booking linked to a room and I'm trying to retrieve only the roomname through roomid a pointer object.

If I use the include parameter the whole room object with all details gets included along with picture data etc.

I just need to retrieve 1 column the roomname.

room details are included through roomid pointer...

Image

Response only specifies specific columns that are being used

Image a rel="nofollow"Image /a


How do I use the include parameter in a query and pull out only selected columns from a pointer ?

Posted: Thu Jan 15, 2015 2:57 pm
by Shawn

ok have been experimenting and here's the update .. I have been able to restrict to 3 columns included through roomid pointer using projection parameter

{ "roomid" : { "roomname":1, "address":1, "addressgeo":1 } }

But my main Booking columns are not appearing. Is there anyway I can also include all columns from the booking collection instead of specifying ':1' for each column ?

Image


How do I use the include parameter in a query and pull out only selected columns from a pointer ?

Posted: Fri Jan 16, 2015 5:27 am
by Yurii Orishchuk

Hi Shawn,

It seems, you got correct and needed result?

So i see you pass to show - code{ "roomid" : { "roomname":1, "address":1, "addressgeo":1 } } /code

And you got it in result..

Details: http://prntscr.com/5t260v/direct

Regards.


How do I use the include parameter in a query and pull out only selected columns from a pointer ?

Posted: Fri Jan 16, 2015 9:51 am
by Shawn

hi yurii

Yes I get the correct room columns but the main booking columns are missing.

I need all booking columns + only selected room columns.


How do I use the include parameter in a query and pull out only selected columns from a pointer ?

Posted: Fri Jan 16, 2015 9:42 pm
by Ihor Didevych

Hi Shawn,

Can you show columns from DB that are missing?


How do I use the include parameter in a query and pull out only selected columns from a pointer ?

Posted: Fri Jan 16, 2015 10:07 pm
by Shawn

hi ihor

none of the booking columns are coming


How do I use the include parameter in a query and pull out only selected columns from a pointer ?

Posted: Fri Jan 16, 2015 10:55 pm
by Shawn

hi ihor

I've been experimenting with this and using something like this ...

{instructions: 1, date: 1, roomid: {roomname: 1, address:1, addressgeo: 1 } }

I've been able to get the required columns so my issue is almost solved.

Image

My only question is instead of having to specify each and every column form my main booking collection can I somehow specify all columns from my main booking collection ?

Because if I use something like this

{ roomid: {roomname: 1, address:1, addressgeo: 1 } }

Only roomid columns are shown and columns from the booking collection go missing

Image


How do I use the include parameter in a query and pull out only selected columns from a pointer ?

Posted: Mon Jan 19, 2015 2:48 pm
by Illya Stepanov

Hi Shawn -

1) You can try create a different service and try to get entity collection instead of changing old one, that is already in use, and in that new service set to response structure only needed columns.

2) Or you can use this response and use only the needed columns.

DB will always return whole entity, remove from the response structure only columns that will be not used.