Filtering projections

How i’m trying to get the projections working but i dont see clearly how they do.

working on the example of the chating room i can see how to get new messages but:

  • ¿How can i get all the messages posted by one given user?
  • ¿how can i get all the events of the type UserJoinedChat to compare diferents chats usage?
    Thanks.

So to be clear you want all the chats of one user to be in one stream
say /streams/{username} and you want a stream of all the UserJoined
events?

Assuming I am correct. Here is a rough typing of the first one.

fromAll().whenAny(
                    function(s, e) {
                            link_to(e.user, e);
                            return null;
                    });

What this does is create a stream name {e.user} that contains links to
events in other streams that the user did.

Example:

in chat room 1. Greg says "hello"
in chat room 1 Neringa says "hi!"

in chat room 2 Neringa says "Hi Greg"
in chat room 2 Greg says "more stuff"

in chat room 47 Greg says "hello"
in chat room 47 Tom says "yo"

would be your initial streams. That projection will create streams

/streams/Greg
in chat room 1. Greg says "hello"
in chat room 2 Greg says "more stuff"
in chat room 47 Greg says "hello"

/streams/Neringa
in chat room 1 Neringa says "hi!"
in chat room 2 Neringa says "Hi Greg"

/streams/Tom
in chat room 47 Tom says "yo"

So now if I wanted to write a projection to count how many chats
people sent I could do a foreach on the Greg/NEringa/Tom streams.

Make sense?

Cheers,

Greg