设置
团结:2019.1.6f1 Firebase版本:6.2.0 Firebase产品:实时数据库
我的使用情况
internal static DatabaseReference Content()
{
return DBReference.Child("content");
}
添加数据
CloudSession.Content().Child(_childNode).SetRawJsonValueAsync(_jsonValue).ContinueWith(
(_task) =>
{
if (_task.IsCanceled == true)
{
Debug.Log("DB UPLOAD Cancelled -> ");
if (_task.Exception is System.AggregateException _aggregateException)
{
if (_aggregateException.InnerExceptions[0] is DatabaseException _innerException)
{
//_innerException.
}
}
}
if (_task.IsFaulted == true)
{
Debug.Log("DB UPLOAD faulted -> ");
}
switch (_task.IsCompleted)
{
case true:
Debug.Log("New value updated!!! -> " + _childNode);
break;
}
Debug.Log("--------- DB COMPLETED ---------");
});
查看数据
CloudSession.Content().Child(_childNode).GetValueAsync().ContinueWith(
(_task) =>
{
if (_task.IsCanceled == true)
{
Debug.Log("DB RETRIVE Cancelled -> " + _task.Exception);
}
if (_task.IsFaulted == true)
{
Debug.Log("DB RETRIVE faulted -> " + _task.Exception);
}
switch (_task.IsCompleted)
{
case true:
Debug.Log("JSON value obtained!!!");
DataSnapshot _snapshot = _task.Result;
}
});
删除数据
CloudSession.Content().Child(_childNode).RemoveValueAsync().ContinueWith(
(_task) =>
{
if (_task.IsCanceled == true)
{
Debug.Log("DB NODE DELETE Cancelled -> " + _task.Exception);
}
if (_task.IsFaulted == true)
{
Debug.Log("DB NODE DELETE faulted -> " + _task.Exception);
}
switch (_task.IsCompleted)
{
case true:
Debug.Log("NODE DELETE COMPLETE-> " + _childNode + " -> "+ _task.Status);
break;
}
});
请求
谢谢