Maintain a reactive object server side?

Hello,

I have built for my last application a normalized data-model. This is a design decision : I do want keep this data model normalized.

But of course, my application needs some denormalizations, and some different denormalizations depending of the use case, of the exact page, of what is the current worklow…

So I would like have an fully-denormlized in-memoy object server-side. I do not have any volumetry issue, neither issue about building the object that all workflows will be able to use.

My problem is : how to get this in-memory server-side object reactive to underlying Mongo collections changes ?

I have tried to publish the object to a named, but non-serialized collection, Works fine when subcribed from the client, but cannot use it from the server.

I have also imagined that - as the published collection is named - it may acts as another collection in where run a find() and so on. But no luck here : find() returns an empty cursor…

In summary, starting from my standard (named, serialized) collections, is it possible to build a reactive consolidated object server-side ?

In my use case, this global object would be used by all users, and the volumetry is not an issue.

Thanks for your help.
Regards
Pierre

Why not just put what you call an in-memory object into a real collection?

Because that would:

  • either duplicate the data, maintenance code and so on…
  • or have to heavily denormalize my data model to provide data to all applicative workflows.

So I would still prefer just relying on some publications for each workflow for the clients…

I’m having a bit of a trouble wrapping my head around this. Could you please provide some example on how you are doing things currently and potentially some pseudo-code on what you have in mind.

Thanks!