This template shows you how to build a presence (understanding which users are online / offline) in Cloud Firestore and Realtime Database.
See file functions/index.js for the code.
The dependencies are listed in functions/package.json.
As an example we'll be using a secure note structure:
/status
/UID_A
state: "online"
/UID_B
state: "offline"
Whenever a new note is created or modified a Function sends the content to be indexed to the Algolia instance.