Practical Microservices: Missing expected version in recordViewing function (page 37)

The function call for the message store is:

// video-tutorials/src/app/record-viewings/index.js
messageStore.write(streamName, viewedEvent)

but the function def is:

// video-tutorials/src/message-store/write.js
return (streamName, message, expectedVersion) => {
 // implementation
}

Is there something I missing?

1 Like

Perhaps a lack in my knowledge of JavaScript and Message DB. Calling the function with the first two parameters will result in expectedVersion to be null. If write_message is invoked with a null then no version check is made. I can see how this behaviour would be desired for logging events compared to managing the state of an aggregate (DDD) where the expected version is important.

2 Likes