Adam DeBray
Posts: 0
Joined: Thu Mar 21, 2013 6:41 am

Database Pointers

I'm working on an app that displays comments. I'm able to query the database to display the list of comments, but one of the fields is a Pointer to the Users Collection. What I want to display is the User's firstname and lastname based on the user id. Is it possible to return the firstname and lastname in one Service Call? In other words can you retrieve information from 2 Collections in one Service Call based on a Pointer field?

If not, then I have to call a different GET Service to get the firstname and lastname based on the user id but at what point would I make this call?

What is the best way to do this?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Database Pointers

Hi Adam,

If there is a field with type = "Pointer" in your collection, then you can add request parameter "include" which value is a Pointer field name (if there are several fields, separate them by commas).

When receiving data, Rest Service will include data pointed by Pointer field.

Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

Database Pointers

Hi,

I have done as you suggested. When I test the service it now shows the included Pointer, but the changes does not reflect when I view my mappings though. "Edit Mappings". What should I do do refresh this?

Kind Regards

Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

Database Pointers

I have managed to refresh it by clicking the "automatically create service response" but all my previous mappings are lost. Is this the correct method then to refresh changes to a service response?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Database Pointers

Hello! Yes, this is how it works - if you recreate response mappings disappears, and you should map parameters to controls again.

Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

Database Pointers

Thank you Marina. The only problem is that you also loose all your custom javascript in the process.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Database Pointers

If I understand you correctly, you had to add one more field to response parameters. You could do that manually without refreshing all response parameter data using "automatically create service response" button. Please take a look here http://docs.tiggzi.com/documentation/...

Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

Database Pointers

Hi Marina. I added the request parameter : "include" to get a Pointer field in my response. The changes did not reflect in my response when viewing the "Edit Mappings" section. I then used the "automatically create service response" method which did refresh the response but unfortunately deleted all my mappings including my custom JavaScript.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Database Pointers

You could add Pointer parameter manually as shown it documentation, but now after you click "automatically create service response" the only one way is to restore missing mapping and JS.

fender
Posts: 0
Joined: Sun Sep 01, 2013 9:03 am

Database Pointers

Hi, does the pointer field need to be populated with the _id from the other collection or does this happen automatically when a record is created? Cheers

Return to “Issues”