Closed xvadim closed 5 years ago
Good point but I think it should already works.
I've made a quick test for that and for Andriod platform it works, I'll check that for other platforms soon. Please take a look: https://github.com/mk-5/gdx-fireapp/blob/2.0.0-develop/e2e/core/src/pl/mk5/gdx/fireapp/e2e/tests/DatabaseReadPojoMapWithKeysTest.java
So you should be able to do something like:
.inReference("/game-rooms")
.readValue(Map.class)
.then(new Consumer(...){ public void accept(Map values){} })
it is what you need, isn't it? :) please let me know - because that is a really good point it should be possibility to received database keys
Thanks for your answer. Unfortunately it works just for readValue, i.e.:
mGamesRef
.readValue(Map.class)
.then(new Consumer<Map>() {
@Override
public void accept(Map map) {
}
});
But for queries:
mGamesRef.orderBy(OrderByMode.ORDER_BY_CHILD, "mSecondPlayer")
.filter(FilterType.EQUAL_TO, "")
.filter(FilterType.LIMIT_FIRST, 1)
.readValue(Map.class)
it crashes:
java.lang.IllegalStateException: Filter should be applied only for the List type at pl.mk5.gdx.fireapp.database.FilteringStateEnsurer.checkFilteringState(
Of course, I can read ALL values and filter its in my code, but it would be nice to have support of filtering out-of-box.
yes, that should be possible.
I'll return to you with something soon; please look forward to an answer here :)
@xvadim I've just deployed the new 2.0.1 version with Map
type allowed for filtering; it should work now, take a look :)
It works! Thanks a lot!!
It would be useful to get keys of list items received via the query I am developing a multiplayer game and need such functionality for implementation game rooms. My idea is next:
readValue should return not just a list of values, but map key=>value
A code will look like:
Another more simple, but not so elegant variant is a public method for access of databasePath property of DatabaseDistribution. In this case code for game room creation may look like:
And the second player can read the room id from the received value.