New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for querying by Tag #26

Closed
aiacovella opened this Issue Aug 25, 2016 · 3 comments

Comments

Projects
None yet
4 participants
@aiacovella

aiacovella commented Aug 25, 2016

EventsByTag and CurrentEventsByTag as documented here would be nice to have and would work well with frameworks like Fun CQRS that support retrievals by Tag.

@trbngr

This comment has been minimized.

Show comment
Hide comment
@trbngr

trbngr Aug 26, 2016

This is currently being explored here.

trbngr commented Aug 26, 2016

This is currently being explored here.

@pawelkaczor

This comment has been minimized.

Show comment
Hide comment
@pawelkaczor

pawelkaczor Jul 1, 2017

Contributor

Could we add support for "by tag" queries, treating tags as stream IDs?

The idea is pretty simple. The akka.persistence.eventstore.EventStoreSerializer would store tags under a meta-attribute "tags":

{
  "jsonClass": "pl.newicom.dddd.messaging.MetaData",
  "content": {
    "causationId": "d3d6a94473894a71a44788016c074b2c",
    "timestamp": "2017-07-01T13:12:31Z",
    "tags": [
      "order"
    ],
    "id": "fdb1712fca4e4d7c8646739da836b168",
    "correlationId": "d60561",
    "target": "akka://ecommerce/system/sharding/order#683687460"
  },
  "$causedBy": "548a3af3-6786-498c-b60a-c5a9c5fb0f80"
}

A continuous projection would link tagged events (events containing the "tags" meta-attribute) to the "tag streams":

fromAll()
    .when({
        $any: function(s,e){
            if (!e.linkMetadataRaw && e.metadataRaw && e.metadataRaw.includes("tags")) {
                var md = JSON.parse(e.metadataRaw);
                if (md.content && md.content.tags) {
                    var tags = md.content.tags;
                    for (var i = 0; i < tags.length; i++) {
                        linkTo(tags[i], e);
                    }
                }
            }
        }
    })
Contributor

pawelkaczor commented Jul 1, 2017

Could we add support for "by tag" queries, treating tags as stream IDs?

The idea is pretty simple. The akka.persistence.eventstore.EventStoreSerializer would store tags under a meta-attribute "tags":

{
  "jsonClass": "pl.newicom.dddd.messaging.MetaData",
  "content": {
    "causationId": "d3d6a94473894a71a44788016c074b2c",
    "timestamp": "2017-07-01T13:12:31Z",
    "tags": [
      "order"
    ],
    "id": "fdb1712fca4e4d7c8646739da836b168",
    "correlationId": "d60561",
    "target": "akka://ecommerce/system/sharding/order#683687460"
  },
  "$causedBy": "548a3af3-6786-498c-b60a-c5a9c5fb0f80"
}

A continuous projection would link tagged events (events containing the "tags" meta-attribute) to the "tag streams":

fromAll()
    .when({
        $any: function(s,e){
            if (!e.linkMetadataRaw && e.metadataRaw && e.metadataRaw.includes("tags")) {
                var md = JSON.parse(e.metadataRaw);
                if (md.content && md.content.tags) {
                    var tags = md.content.tags;
                    for (var i = 0; i < tags.length; i++) {
                        linkTo(tags[i], e);
                    }
                }
            }
        }
    })

pawelkaczor added a commit to pawelkaczor/EventStore.Akka.Persistence that referenced this issue Jul 11, 2017

@pawelkaczor

This comment has been minimized.

Show comment
Hide comment
@pawelkaczor

pawelkaczor Jul 11, 2017

Contributor

@t3hnar Thanks for the merge and the release. You can close the ticket.

Contributor

pawelkaczor commented Jul 11, 2017

@t3hnar Thanks for the merge and the release. You can close the ticket.

@t3hnar t3hnar closed this Jul 11, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment