Hacker News new | ask | show | jobs
by raeldc 2581 days ago
We use NestJS/CQRS in our property management app. Here's how we implement it:

1. There are 2 event handlers for "writes". One handler writes normalized data in a PostgreSQL DB. The other handler writes denormalized data into Firestore. 2. Our frontend uses Firestore so mutations are reflected realtime in the frontend. We never found a need for the command to return data. There is also no need for complex queries in Firestore since our data is denormalized and optimized for reads. 3. The PostgreSQL DB is useful for reporting and complex queries. Our frontend app displays this data only in the reports area.

So far, I don't see how things can get confusing with this pattern.

2 comments

Does error handling exist in your application or did you guys take the "happy path" only exists?
What problem does CQRS solve in this scenario?
This is a good example of What CQRS really is. Separate read/write in a system.

It's in fact a very simple pattern. But I wouldn't use it system wide because not everything has to be eventuel consitent.

Isn’t all reads and writes already separated?