step-up-labs / firebase-database-dotnet

C# library for Firebase Realtime Database.
MIT License
668 stars 168 forks source link

How to detect if node does not exists #292

Open L10Messi10 opened 1 year ago

L10Messi10 commented 1 year ago

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 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;
    }`