how to get data from Firebase Cloud Firestore in Kotlin - android

So I have a database in Firebase Cloud Firestore that stores users and tasks. Each user has a number of fields such as name, username,etc. I want to know how to fetch each field that is associated with each user using Kotlin.
I'm trying to get all these accounts so I can display them in an activity called friends, that's why I want to collect all these accounts from the database. Here is a picture of my database to have a clear understanding of what I'm trying to do.

Related

Compare two lists in firebase query

In android, I have a list generated by user input which needs to be compared to a list in Firebase Realtime Database. I want to compare if List 1 contains all the elements in List 2.
This data then needs to be displayed in FirebaseRecyclerPagingAdapter.
Is there anyway this can be achieved?
There is no way to compare two lists in a single operation on the Firebase Realtime Database (nor on Cloud Firestore for those wondering). You will have to load the relevant lists from the database and perform the comparison inside your application code.

generate a Firebase Cloud Function for each Firebase user in the database?

I want to to have a Firebase Cloud Function that do some mathematical equation to my user information that is stored on my database, I want it to be triggered when a user update his information. How I can get a database reference to all my child nodes in the data base . is there a way to generate a function when a user is created which will be triggered with his database reference that way i will have a function for each user created?

Firebase asynchronous query - matching results

Hello fellow developers,
I have a question about getting the data from Firebase. Trying to compare the transactions list of one user with another user in a function. Two separate hashmaps are used to store the data (transaction list) of each user. Then I loop through the list of records of first user and try to match with the records of the second user. Since Firebase is asynchronous, function skips before I get the data. I need some ideas to manage the asynchronous fetching of data from Firebase.
Thanks

How to display data uploaded by different users in a general list through firebase

I am making an app in which the user will authenticate themselves and store information, say related to food detail. Firebase will store this information corresponding to each userID. I want that whenever any user opens the app, he should see a list of all the food details uploaded by different users. I know only how to access data of the current user. Even for a particular user, i want to access a given field of all users present in Firebase realtime database.
From all the info available from your question, here are my points in my experience i would have done.
you will have to have these data for the food stored in a common location where your security rules permits for read and write but only if the user is authenticated
realtime database security rules documentation
next, I will keep all these food data in the common location as earlier said and a condensed version of it at each user's hierarchical level with the same identifier( document id or reference) as in the common location for easy retrieval should I want to.
working with a list of data in firebase realtime database at this stage, assuming you will be loading it into a listview/recyclerview, on receival of new object, you can just load it into your adapter and you are good to go.
Even for a particular user, i want to access a given field of all users present in Firebase realtime database.
Just make them security rules to that field readable by any logged in user and then, use the following link to know how to access the data.
reading data from firebase realtime database. Hope this helps. If you want more explanation, give more details on your use case and the hierarchical structure of your database.

Send data to Realm object server from app

I am creating an Android application in which I am using the Realm database to store data, and I am using the Realm object server to login and register user. I am able to log a user in using SyncUser and I am able to see that my login user has been stored in the Realm object server.
But now I have additional fields that I want to store - for instance, mail and age. I know how I'd store it in a different database but I don't know how to do this in Realm.
If you are talking about storing metadata about a user. That is not supported yet, but will be added soon. You can follow https://github.com/realm/realm-java/issues/4645. For now the workaround would be to save them in your own custom User Object.

Categories

Resources