firebase-database-dotnet icon indicating copy to clipboard operation
firebase-database-dotnet copied to clipboard

How to detect if node does not exists

Open L10Messi10 opened this issue 3 years ago • 0 comments

Hello, I'm working on a real-time database. And I want to know if is there a way to detect if the node has existed?

The code below displays the subject of a teacher within the school on the student app, but I have another app that would remove the "classkey" (on the teacher's app). The problem here is; When calling this function, it doesn't give an error or so for me to catch that error and notify the student that the class for these subjects has been removed. So I'm wondering, is there a way to check if the key for that node has existed or not?

`public ObservableCollection<Subjects> GetClassSubjects(string classkey) {

        //This code must detect if the node is available or not
        var subjects = client
            .Child($"Schools/{schoolKey}/Teachers/{T_Key}/MyClass/{classkey}/Subjects")
            .AsObservable<Subjects>()
            .AsObservableCollection();
        return subjects;
    }`

L10Messi10 avatar Jul 16 '22 00:07 L10Messi10