Git Product home page Git Product logo

Comments (5)

adrai avatar adrai commented on September 27, 2024

getFromSnapshot simply returns a snapshot and depending on the version describing that snapshot you can handle it... for example you can convert it... i.e. https://github.com/adrai/node-cqrs-domain/blob/master/lib/definitions/aggregate.js#L652

from node-eventstore.

rehia avatar rehia commented on September 27, 2024

Hi @adrai,

Instead of creating a new issue, I prefer to ask my question here.
Actually, I have the same question: How could I easily get only the latest snapshot (with only the new events), without knowing the current revision ?

I'm using redis store, and it seems that the snapshots are all scanned by default (using revMax === -1).
I was using snapshots to enhance performance because of a lot of events on an aggregate. But it won't if all snapshots are scanned.
And I don't have the current revision of the aggregate because the time I'm reloading the aggregate form a snapshot.

Looking at the code of redis storage, I thought passing 1 as revMax would avoid many useless GET on redis, because of these lines:
https://github.com/adrai/node-eventstore/blob/831698514af8bfb0d6d8c0f65e139250e1bb7b3a/lib/databases/redis.js#L579-L585
The snapshot keys are reduced to the last snapshot key.

But once the snapshot is loaded, it is filtered because its revision (usually above 1) doesn't fit this filter:
https://github.com/adrai/node-eventstore/blob/831698514af8bfb0d6d8c0f65e139250e1bb7b3a/lib/databases/redis.js#L606

So I feel like, if I want the latest snapshot, I need to pass the the "real" revision, but by doing this, all of the snapshots will be loaded, hence causing some "n+1 selects" issue with no need.

Correct me if I'm wrong. Thanks for your awesome work. I would love to help.

from node-eventstore.

rehia avatar rehia commented on September 27, 2024

By the way, we can also reverse the question by asking: how is it possible to get the snapshot of revision 1, if there is already a snapshot for revision 4 ?

from node-eventstore.

rehia avatar rehia commented on September 27, 2024

Finally made a pull request to improve the way snapshots are loaded.

from node-eventstore.

adrai avatar adrai commented on September 27, 2024

Sorry, had no time to take a look at it...
Will look at it asap.
Thanks for your contribution.

from node-eventstore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.