I want to use Cloud Firestore for generating notifications for the changes in the database.
However, the database structure is a bit complex and I am not sure how I can create the design for generating presence notifications using Google Cloud solutions.
Basic structure of database should be like following
{
"Users" : {
"A" : {
"Time" : "10:07",
"presence" : "busy"
"Watchers": [ B, C, D ]
},
"B" : {
"Time" : "10:08",
"presence" : "busy"
"Watchers": [A,C,D]
}
},
"Watchers" : {
"A" : {
"Client_1" : {
"Presence_reference" : [ B, C, D]
},
"Client_1" : {
"Presence_reference" : [ B , C]
}
}
"B" : {
"Client_1" : {
"Presence_reference" : [ A, C, D]
},
"Client_1" : {
"Presence_reference" : [ A , C]
}
}
"C" : {
"Client_1" : {
"Presence_reference" : [ A, B, D]
},
"Client_1" : {
"Presence_reference" : [ A , B]
}
}
"D" : {
"Client_1" : {
"Presence_reference" : [ A, B, C]
},
"Client_1" : {
"Presence_reference" : [ A , B]
}
}
}
}
As you can see above the publishers of presence will keep list of watchers and watchers will also keep list of presentities that they want to look at.
My main issue is lets say the client wants to get a notification of the changes happening in the presence of Presentities above. In this case, considering a minimalistic client like an IoT device which has Curl API support, will it be possible to:
- Get the notifications to Watcher IoT clients for the changes happening in all of the Presentities that the watcher is looking at. Currently as far as I know I need to provide path to Firebase which I am monitoring as a client. However there could be many presentities which I want to monitor, its not clear how to provide the multiple monitoring paths at client side. I understand that we can duplicate the presence of presentities in every watcher's data, but that would be like too much of data getting duplicated for each watcher. How do I create a reference of all the presentities I as a watcher want to look at?
- I also understand we can use Cloud Firestore with Cloud functions to generate the notifications for the clients, which I am not clear about. Any idea in this regard as to how to go about efficiently designing such system would be helpful.