【发布时间】:2017-08-01 21:27:31
【问题描述】:
这是我在 Firebase 上上传的模型:
public class OnlineMatch{
private User user1;
private User user2;
public OnlineMatch(User firstPlayer, User secondPlayer) {
this.user1 = firstPlayer;
this.user2 = secondPlayer;
}
}
然后我以这种方式(kotlin)将数据发送到 Firebase:
fun createMatch(match: OnlineMatch) {
val matchList = database.child("multiplayer").push()
matchList.setValue(match)
}
因此,我的数据库结构如下:
如果我展开一个节点,我可以完美地看到我的对象: OnlineMatch(User1, User2)
现在我想查询数据库并获得一个 ArrayList''。 我已经找到了 Firebase 文档,但没有发现任何有用的东西。 我能怎么做?提前致谢。
【问题讨论】:
-
我想补充一点,我的 OnlineMatch 类具有根据 Java 约定 (camelCase) 编写的正确 setter/getter:setUser1, getUser1 ecc
标签: android firebase firebase-realtime-database kotlin