April 2020
Intermediate to advanced
292 pages
6h 50m
English
Technically, we don’t have to do anything to support $any, since we did that backhere when we wrote the subscribe functionality’s handleMessage function. That was too good of a header to pass up though.
Let’s jump into the Message Store’s read functionality to provide messages for $all:
| | const getAllMessagesSql = ` |
| | SELECT |
| | id::varchar, |
| | stream_name::varchar, |
| | type::varchar, |
| | position::bigint, |
| | global_position::bigint, |
| | data::varchar, |
| | metadata::varchar, |
| | time::timestamp |
| | FROM |
| | messages |
| | WHERE |
| | global_position > $1 |
| | LIMIT $2` |
| | function read (streamName, fromPosition = 0, maxMessages = 1000) { |
| | let |
Read now
Unlock full access