I want to save the data on Firebase, that a user describes on an Intent. The saved data should be used to find one or more matching users with similar informations.
Thanks in forward.
Looks like you are building an app where you can clusters users with similar interests about particular thing, i would suggest you to use firebase firestore for storing data, and you can retrieve data that are similar using the firebase simple and compound query depending on your requirement.
Related
I'm developing an Android app with Java and using Firestore, It's a social network and I have a collection with all the posts. I'm trying to show only those posts that belong to the followed users, so I make a query to show all the posts ordered by timestamp, but I don't know if I can filtered them by comparing with the collection "followed" inside "User".
The main collection "Users" has documents, each of them is a user, inside every user there is a subcollection "followed" that contains the followed users, every document is a user and the document id is the same that the User ID.
The posts are stored in another main collection called Posts, so I need to compare the id User inside "Posts" documents with the id of the docs in the subcollection "followed". I hope somebody can help me, I spent a lot of time and I can't find anything, thank you.
Firestore does not have the ability to "join" documents in collections as you're describing here. It's relatively straightforward in SQL (if your server has enough memory), but Firestore (and other NoSQL databases) aren't built for this, due to its distributed nature, and the way it needs to scale.
The only way to do what you want is to write code to read every document in every collection that would need a comparison, and also perform that comparison with the documents in memory.
I've been using Firebase in android apps for a while now and I was wondering if it would be at all possible for when a user creates an account (using Firebase authentication) it also creates a Firestore database linked to that account and only that account? I would also like it so that when the user deletes their account, the database is removed with it. I was looking into other database options but Firestore seems to be the best option for what I want to do.
Let me know if this needs clarification!
In your case one firestore database will work perfectly. You will need to do some thinking on database structure
This video will help https://youtu.be/haMOUb3KVSo
You shouldn't create a database for each user, it will become really messy when your code and userbase grows. Also there is no way to create databases programmatically.
So I am wondering about how necessary it is to store variables in the realtime firebase database if I want all Users at access the same dynamic variable.
So for instance, I have a arraylist that stores the list of open games, and if I want this list to update in realtime for every user should this List in firebase realtime database?
Sorry for the simplicity of the question
Yes, it may be a simple question, but it surely pops in head of everyone, once.
I think for updating any list dynamically in real time, would require you to access any kind of database.
It is not necessary to have it on Firebase database, but any database online, that can tell every open instance of your app that the list has to be updated at a particular instant.
The main reason of why you need it to be on database is updating it in real time and that too dynamically.
If it's not dynamic, meaning the content that you need, can be hardcoded then one way would be placing everything you need in your code and using timer or something like that to fire at particular moments to update things in your app.
Also that aside, sorting, storing and changing data is much simpler using a database, which also becomes one more reason for you to use a database like Firebase to keep content of your app that has to be updated frequently in real time.
You can know more about database in this Google link, I found.
I was trying to develop an mobile app which have some similar idea just like Uber, which is real time update driver & customer location. So here I am seeking for suggestion for what I was thinking for the app structure.
For what I research, in order to provide fast real time update location, I may need to make use of real time database such as Firebase for the backend. So, I was thinking to combine 2 different type of database to achieve what I was thinking...
Firebase - For real time fast update user location
MySQL - For backend api business logic
However, I have no experience with firebase, so I hope you all can give some advise. I plan to only store the user location coordinate information in firebase database, then retrieve it from mobile app to update realtime.
My problem is I not sure should I forever persist those driver coordinate data in firebase database? Since the coordinate data keep changing update in firebase, so should I delete those coordinate data from firebase as soon as the driver have reach the destination. (No need to keep those data persist, only real time data keep change on firebase)
Thanks for reading such long question, I will also happy that if you all can remind to me any other concern if I use 2 different database for my application.
You'll typically keep a list of drivers and their locations in Firebase:
driverlocations
driver1id: location
driver2id: location
This means that you're not adding new data, but updating existing data. So you don't have to worry about the list constantly growing.
To ensure you don't have stale data for drivers that closed the app/stopped driving, you can use Firebase's onDisconnect() handlers to remove the data when they disconnect.
Now querying this data for nearby drivers is still tricky. You'll want to look at GeoFire for that. I recently explained why that is needed and how it works here: Sort array by distance near user location from firebase
I'm developing an app on Android using Firebase that should embed a chat.
My issue is that to fetch messages, I need to query all the messages which have my uid either in sender or receiver field. This would be extremely easy to do in MySQL, but in Firebase (I must stick onto Firebase) looks kinda pain.
I cannot just filter them like that. And being receiver and sender fields of the object inside chat, I cannot even just filter them when I'm using a Firebase url like firebase.myapp.io/chat.
So the only possible solution in this model, is fetching all the chats and client-filtering them. This is all but good way to do this job. Also, when the message will be many, if they should, everything could become extremely slow.
So I thought about different ways to achieve the result:
I get in chat the keys corresponding to user uid. Among the values, I get chats from user point of view, or I got the keys of my receivers as values, and inside the messages
But I don't like this very much since it can be extremely redundant, since every message should be inserted twice in the db.
Another way would be memorizing messages keys into another object, like chatmessages, and inside I got users uids as values, and as keys containing chat message keys.
What would be the best NoSQL way to manage multiple, private chat conversations?
I currently have the same problem with a chat application am creating. I recently found a solution:
1) I basically used the two users unique ID and converted them to a number using ID.getBytes().
2)Then I added the 2 numbers one to the other (addition) and converted them to a base64 number again.
3) Used the resulting number as the id for the chatroom.
It worked but since am doing all thisfor a android app it shows me a warning that am doing too much work on the main thread.
Let me know if anyone knows a better way to do that!