last day (15 days later) » 

1:46 PM
0
A: How to write back end server code in Firebase

Alex MamoTo actually write a function you need to access your Firebase console, choose an project and on the left side, select the last section named (...) Functions, as in the below image. Why to use Cloud Functions for Firebase? You should use it because lets you automatically run backend code in res...

 
What i want is my app should generate a get request to the server to get order details ( like e-commerce app) and app should receive only that order details which is near to that app location. I think this can't be done by cloud function or firebase database rule. Any help.
 
In this case, you need to query your database using a condition. And this must be done client side. After that you need to attach a listener. And you are right, this cannot be done using Cloud Function or Firebase security rules.
 
So, how it can be done client side because server has to maintain that which order is delivered to which app user.
 
Without seeing some code, it's hard for me to say. But assuming you have a node in which you have orders and assuming again that each order has data for positioning, all you need do, is to query your database to see which order is closer to a specific location. That's it.
 
Yeah, that's what i want.
 
1:46 PM
This is basically another question, which is not related to the initial one. In order to follow the rules of this comunity, please post another fresh question, so me and other users can help you. Don't forget to add an mcve so all users to have a better understanding.
If you think that my answer helped you for the initial question, please consider accepting it and giving a vote up. Thanks!
Witout code, nobody can help you.
That's why i asked you to add a second question, regarding this new issue
 
@AlexMamo How I can write the code if i don't know whether that functionality can be implemented by Firebase.
And I think both problem is same. Can you please tell me the difference?
 
This functionality can be implemented by Firebase. There are many apps over the internet which have this kind of functionality.
You asked "How to write back end server code in Firebase" and you got the answer. Now you are asking how to query a database. There are different concepts.
So, in other words, different questions.
So if you asked for my help, please do as requested. Post another fresh question regarding this issue.
 
Nah i am not asking how to write query on database. What i want is how to write some algorithm on Firebase Database not on client side but on Firebase server side.
 
Cloud Functions won't help you query your database to see which order is closer to a specific location.
 
See i have some function foo() that take all the order detail from database and do some computation and return it to my app. So how to accomplish this. Is it possible by using firebase or not?
 
1:59 PM
Yes it is. You need to create a condition, in stead of getting all orders, you need to filter those order based on location. So you need to get all orders which are closer to a specific location.
Then you can add a flag for each order with the default value of false. If the device is near your desired location, change the value to true. In the end write a function in Cloud Function to verify if the value is true. If it's true, then send a notification.
This is how things are working in Firebase.
Hope i was clear enough
 
I am asking where to write that foo() function that do computation and return result directly to the app user.
Because foo() is not cloud function
 
In you application. There must you write the function.
You downvoted my answer?
 
See I don't want to fetch all data from Database then apply the algorithm. That i know. I want that server does the computation and return required data to me. And app just blindly receive that data and show to the user. That's it.
@AlexMamo Sorry, But It does not helped me.
 

last day (15 days later) »