{"action":"created","issue":{"url":"https://api.github.com/repos/adrai/node-eventstore/issues/24","repository_url":"https://api.github.com/repos/adrai/node-eventstore","labels_url":"https://api.github.com/repos/adrai/node-eventstore/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/adrai/node-eventstore/issues/24/comments","events_url":"https://api.github.com/repos/adrai/node-eventstore/issues/24/events","html_url":"https://github.com/adrai/node-eventstore/issues/24","id":49092814,"number":24,"title":"multiple snapshots: how to do `getFromSnapshot` using `version`","user":{"login":"gebrits","id":393259,"avatar_url":"https://avatars.githubusercontent.com/u/393259?v=3","gravatar_id":"","url":"https://api.github.com/users/gebrits","html_url":"https://github.com/gebrits","followers_url":"https://api.github.com/users/gebrits/followers","following_url":"https://api.github.com/users/gebrits/following{/other_user}","gists_url":"https://api.github.com/users/gebrits/gists{/gist_id}","starred_url":"https://api.github.com/users/gebrits/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gebrits/subscriptions","organizations_url":"https://api.github.com/users/gebrits/orgs","repos_url":"https://api.github.com/users/gebrits/repos","events_url":"https://api.github.com/users/gebrits/events{/privacy}","received_events_url":"https://api.github.com/users/gebrits/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2014-11-17T14:03:31Z","updated_at":"2016-11-02T16:23:28Z","closed_at":"2015-03-24T13:20:52Z","body":"Browsing through the docs and this looks great. \n\nOne thing that caught my eye, is that I want to create a new snapshot after N events have happened. This results in M snapshots over time that I want to be versioned.\n\n`createSnapshot` allows me to define an optional `version`. Normally I'd like to retrieve the latest snapshot (is there a shortcut to get to the latest without defining a `version` ? ) but sometimes I want to fetch an arbitrary `version`. However, `getFromSnapshot` (at least from the docs) doesn't seem to allow to pass `version`\n\nHow to do this? \n"},"comment":{"url":"https://api.github.com/repos/adrai/node-eventstore/issues/comments/257917286","html_url":"https://github.com/adrai/node-eventstore/issues/24#issuecomment-257917286","issue_url":"https://api.github.com/repos/adrai/node-eventstore/issues/24","id":257917286,"user":{"login":"rehia","id":2240738,"avatar_url":"https://avatars.githubusercontent.com/u/2240738?v=3","gravatar_id":"","url":"https://api.github.com/users/rehia","html_url":"https://github.com/rehia","followers_url":"https://api.github.com/users/rehia/followers","following_url":"https://api.github.com/users/rehia/following{/other_user}","gists_url":"https://api.github.com/users/rehia/gists{/gist_id}","starred_url":"https://api.github.com/users/rehia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rehia/subscriptions","organizations_url":"https://api.github.com/users/rehia/orgs","repos_url":"https://api.github.com/users/rehia/repos","events_url":"https://api.github.com/users/rehia/events{/privacy}","received_events_url":"https://api.github.com/users/rehia/received_events","type":"User","site_admin":false},"created_at":"2016-11-02T16:23:28Z","updated_at":"2016-11-02T16:23:28Z","body":"Hi @adrai,\r\n\r\nInstead of creating a new issue, I prefer to ask my question here.\r\nActually, I have the same question: How could I easily get only the latest snapshot (with only the new events), without knowing the current revision ?\r\n\r\nI'm using redis store, and it seems that the snapshots are all scanned by default (using `revMax === -1`). \r\nI was using snapshots to enhance performance because of a lot of events on an aggregate. But it won't if all snapshots are scanned.\r\nAnd I don't have the current revision of the aggregate because the time I'm reloading the aggregate form a snapshot.\r\n\r\nLooking at the code of redis storage, I thought passing `1` as `revMax` would avoid many useless `GET` on redis, because of these lines:\r\nhttps://github.com/adrai/node-eventstore/blob/831698514af8bfb0d6d8c0f65e139250e1bb7b3a/lib/databases/redis.js#L579-L585\r\nThe snapshot keys are reduced to the last snapshot key.\r\n\r\nBut once the snapshot is loaded, it is filtered because its revision (usually above `1`) doesn't fit this filter:\r\nhttps://github.com/adrai/node-eventstore/blob/831698514af8bfb0d6d8c0f65e139250e1bb7b3a/lib/databases/redis.js#L606 \r\n\r\nSo 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.\r\n\r\nCorrect me if I'm wrong. Thanks for your awesome work. I would love to help."}}
{"actor":{"display_login":"rehia"}}