Shawn
Posts: 0
Joined: Sat Jun 21, 2014 11:13 pm

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

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

Shawn
Posts: 0
Joined: Sat Jun 21, 2014 11:13 pm

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

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

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

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

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.

Shawn
Posts: 0
Joined: Sat Jun 21, 2014 11:13 pm

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

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.

Ihor Didevych
Posts: 0
Joined: Wed Nov 19, 2014 7:55 pm

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

Hi Shawn,

Can you show columns from DB that are missing?

Shawn
Posts: 0
Joined: Sat Jun 21, 2014 11:13 pm

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

hi ihor

none of the booking columns are coming

Shawn
Posts: 0
Joined: Sat Jun 21, 2014 11:13 pm

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

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

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

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

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.

Return to “Issues”