Get most recent geo and other user info

0 votes
Hello,

It is related question to what I asked and I am not sure which design I should follow. I dont want to start off the wrong path and figure out I was wrong. Therefore your advice is highly appreciated.

I basically want to insert user Id, geo info and date it was added. Also, I use the userservice product which link userID to its profile. In addition, I want to have other customized user information (say 5 data columns per user)

Basicially, I want to do two queries at different times like that:

1- Get me user profile, 5 data fields of all the users whose "Latest" geo info are within a certain km range of sepecif lat/lng

2- Update the 5 datafields of user to be equal to {...} where userId = x

 

My questions are:

1-- Would you put the 5 datafields in the same DB/collection as the userId,Geo,Date.. basically all in one JSON

OR would you put the 5 datafields in another collection where it is referenced by userID ( I prefer this for segregation of information and to follow DB design standard).

 

2- How can you do the above query going across different products ( and potentially across different collections) keeping in mind we are return recent data only?

 

I hope you get my question.

Thank you so much
asked Nov 27, 2014 in App42 Cloud API-BaaS by AndroidFolk (107 points)

1 Answer

0 votes

Hi AndroidFolk,

Thanks for detail input. Please see my answer below inline

Q1-- Would you put the 5 datafields in the same DB/collection as the userId,Geo,Date.. basically all in one JSON 

OR would you put the 5 datafields in another collection where it is referenced by userID ( I prefer this for segregation of information and to follow DB design standard).

ANSWER >> You can use either way however it is all driven from UI design that you have. If you want to show all information in the app on the same page, you can use same collection to dump all information. However if UI has first page as basic information and then detail information on profile page, you can separate in two different collections. In this case you have to make another call to App42 if user cicks on detail information link and you will pass userId as reference which is being used in another collection for storing the data.

 

Q2- How can you do the above query going across different products ( and potentially across different collections) keeping in mind we are return recent data only?

ANSWER >>> As I explained before, you can make use of UserID or any other reference Id to make a query in another collection. There is no join operation support in NoSQL based db and you have to make another call to fetch data back in the app.

 

Let me know if it answers your question.

Thanks

AJay

 

answered Nov 27, 2014 by ajay123 (899 points)
Hello
Thank you for answering my question. The problem with the second question is that if I just query on geo I might get a huuuge result set from the server(time to download plus app processing). I read through the docs and forum and it seems I can use server custom code. Will that make things faster and better in your mind.
Yes, using custom code will help you in aggregating the things on server and doing the process right there instead of client side. Since it is server to server call it is going to be faster and will make sense in your case.
I hope your query has been resolved, kindly let us know if you have more questions for us.
Thanks,
Himanshu Sharma
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...