Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RavenDB Push Notifications: Actual document not included?

Tags:

ravendb

I've successfully implemented push notifications with RavenDB (see code below). I was expecting the actual document to be included with the change notification. That way, all the UI clients can display the information. However, it seems that only the Id and Etag properties are available for the changed document.

What am I supposed to do if I want the client to be able to display information about the document? Does the client now need to make a DB call to get the document based on the ID? It seems inefficient to have to make a DB call to get the information. But, is that what is supposed to happen?

documentStore.Changes()
    .ForDocumentsStartingWith("LogMessages")
    .Subscribe(change =>
    {
        if (change.Type == DocumentChangeTypes.Put)
        {
            // Fire event so consumers can display document info
            // Uh oh, are change.Id and change.Etag all we have here?
            DatabaseItemAdded(null, new EventArgs<string>(change.Id));
        }
});
like image 806
Bob Horn Avatar asked Jan 24 '26 20:01

Bob Horn


1 Answers

Yes, you need to call the db to get the new document. The reason for that is that it would be expensive to send the document (which may be very big) if all you need is just the notification on the change).

like image 112
Ayende Rahien Avatar answered Jan 28 '26 15:01

Ayende Rahien