I'm a big fan of Firebase and that is the reason I've decided to use it in my current app, but I've got to a point where I no longer know if it can support my needs.
App functionality is the same as "Tinder" app, you can swipe like/unlike on people based on their gender, location, and age.
I've noticed there is no reason having more than one query at a time, so I'm saving each person at a path based on its gender, and the "key" is a "push key" firebase generates. I'm using the "push key", because It's indexed, so the user will not swipe twice the same user. (Swiping will start from the first user that joined the system)
let lookForGender = "female"
//swipingIndex is the last user index I've swiped.
let baseRef = firebaseApp.database().ref("lookForGender")
.startAt(null, currentUser.swipingIndex);
baseRef.once('value', function (snapshot) {
UsersFeedService.updateState(snapshot);
})
//DB looks like:
"female"
someIndexKey
userObject
someIndexKey
userObject
"male"
someIndexKey
userObject
someIndexKey
userObject
This works well, but now I'm looking for a way of getting only people near me, for that I've added “GeoFire”, but It has to work on its own “key”. And I can not save users by location keys because then they will not be indexed (So user will only swipe once on each user).
Geo location would like the db to look something like this:
“location”
userObject
“location”
userObject
“location”
userObject
“location”
userObject
Getting a snapshot of all users and iterating between them is not an option since they maybe are a lot of users.
Is this something that's possible to achieve with firebase? I'm I not structuring the data in the right way? And if so, how should I?