In the noonjs, whenever a collection undergoes a change (create, update, or delete), an event is triggered, notifying all clients specified in config.json.
If io is true, it indicates that the event originated from the server, meaning the document might contain fields filtered based on user permissions.
The created event is triggered when a new document is added to the collection.
client.collection("todos").on("created", (todo, io) => {
// do something with todo
})
The updated event is triggered when an existing document in the collection is modified. The received todo object contains the updated data.
client.collection("todos").on("updated", (todo, io) => {
// do something with todo
})
The deleted event is triggered when a document is removed from the collection. The todo object contains the removed document's details.
client.collection("todos").on("deleted", (todo, io) => {
})