ES impl of aggroot in Nodejs

== sorry I forgot to add node to the subject line. so I deleted and readded.

Hey,
I have some really sweet architecture for connecting to eventstore and populating agg roots etc. I jacked most of it from examples and stuff. I’m very pleased with it. But it’s in c# and I’m done. I just can’t take it anymore. I’m off the boat. I’m already using a node api, but sending commands to my C# Domain layer. I’m starting to think about re-implementing it in node. I know there are two apis, but I was wondering if anyone had attempted something like the AggregateBase or the ES repository in node?

Node kind of has me feeling a bit functional or maybe just not so OO. But I guess an app still needs AggregateRoots to hold state. But I’m also open to other suggestions. Provided they work with ES.

Thanks,

R

My concern would be to make the system type safe unless you use typescript or coffeescript.

Meh, type safe is a safty net/straight jacket. It keeps you safe at the cost of mobility.

Hi Raif,

I have done some event sourcing with aggregates in node, but I used a homegrown event store with the idea that I would migrate to a GES based version when someone wrote a nodejs client. A year later, I had to write the client myself, and now 6 months after that, I am finally going to integrate it. The code is proprietary, but it’s exactly what you’d expect if you’re working in C#.

Aggregates in JavaScript can be exactly the same as their C# counterparts. It’s an easy transition. Projections are also very simple too. I have a projection library that I wrote that is somewhat gnarly right now, but can be backed by in-memory (works in browser) storage, level db storage, nedb storage, and static files. It needs some cleanup and a lot of documentation, but it has been in production for almost 2 years.

https://github.com/bmavity/bjorling

This library will also be going through some cleanup/enhancements in the next month or two.

So do you use a base class for the aggregates to manage the uncommited events and routes etc. Would you recommend the new class object in es6? I never much liked the doing the prototype inheritance.
Thanks for the input,
R

Hi Raif,

You could certainly use ES6 classes. As this was a couple of years ago, I used a mixin that looks something like this

https://gist.github.com/bmavity/1150f53e0239a283353c

Many ways to tackle this problem. Just go with whatever pleases your aesthetic. :slight_smile:

Cant we all just get along https://www.youtube.com/watch?v=1sONfxPCTU0

Cool, thanks. This is the first piece of non trivial code I’ve tried to port to node, and i may just be stalling cuz im nervous. But your right, that looks pretty much just like my c# code :slight_smile:
R