gpt4 book ai didi

java - unity firebase 数据库检索数据

转载 作者:行者123 更新时间:2023-12-02 02:18:47 24 4
gpt4 key购买 nike

如何获得从 Firebase 检索特定子项数据的正确方法或快捷方式或最快方法

baseRef.Child ("wordRun").Child("Players").Child(userid).Child("GameRun").Child("usercount").GetValueAsync ();

我尝试做一些事情:-示例1

var getTask =baseRef.Child ("wordRun").Child("Players").Child(userid).Child("GameRun").Child("usercount").GetValueAsync ();

yield return new WaitUntil(() => getTask.IsCompleted || getTask.IsFaulted);

if (getTask.IsCompleted) {
Debug.Log(getTask.Result.Value.ToString());
}

示例 2:-

baseRef.Child("wordRun").Child("Players").Child(userid).Child("GameRun").Child("usercount").GetValueAsync .ContinueWith(task => {
if (task.IsFaulted) {
// Handle the error...
}
else if (task.IsCompleted) {
DataSnapshot snapshot = task.Result;
foreach ( DataSnapshot user in snapshot.Children){
IDictionary dictUser = (IDictionary)user.Value;
Debug.Log ("" + dictUser["usercount"]);
}
}
});

我想在 firebase 数据库中写入一行值,如果有人知道如何在 firebase 中的一行中获取值,那么请给出答案,谢谢您的阅读...

请给我一种通过获取 GetRawJsonValue 来获取类中所有数据的方法

最佳答案

你需要绕过循环

foreach (var childSnapshot in args.Children) { 

Debug.Log("ChildSnapshot"+childSnapshot..GetRawJsonValue());

}

如果您有任何具有相同数据格式的类,那么您可以尝试这个

ClassName ClassObjectName = JsonUtility.FromJson<ClassName>(args.Snapshot.GetRawJsonValue());

关于java - unity firebase 数据库检索数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48860880/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com