EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 446 forks source link

Path to value with Wildcard #1384

Open carlosdelfino opened 5 years ago

carlosdelfino commented 5 years ago

I am developing a tracking app where there are one or two tens of thousands of markers on a map that need to be monitored, the data structure is simple:

    users: {
        000001: {
            name: "Carlos Delfino",
            desription: "Administrador",
            roles: [...]
            others...,
            lastPosition: {lat: -3, lgt: 48}
        },
        000002: {
            name: "Outro usuário",
            desription: "",
            roles: [...]
            others...,
            lastPosition: {lat: -3, lgt: 48}
        }
    }
    users_history_position:{
        000001: {
            "7777777777":{lat: -3.3, lgt: 48.3},
            "7777777877":{lat: -3.4, lgt: 48.3},
            "7777797777":{lat: -3.4, lgt: 48.5},
        }
    }

But I need to know when each of them has only their geolocation changed, is there a way to use wildcards for change listeners?

In this case the path would be similar to:

var onValueEvent = function(result) {
    if(result.value)  googleMapsUpdateMarker(result,key, result.value.lat,result.value.lgt);
};

// path to lastposition of all users.
firebase.addValueEventListener(onValueEvent, "/users/*/lastPosition");

What is the best way to implement such code using nativescript-plugin-firebase?

EddyVerbruggen commented 5 years ago

What would be the way to do this with the Firebase SDK?