Skip to content

Populate Projection with multiple tables #59

@webdevilopers

Description

@webdevilopers

Came from:

Here is a current example where we need to get guest data from a different stream before we insert a related (guestId) visit data - promoting the unique ID - at all.
What are the options beside event enriching? Separate repository calls sound like a bad idea.

projection
readmodel

As suggested by @prooph and @gquemener for SQL projections:

Instead of storing guest data in projection state, write it to a table that is only used by the projection.

IIUC, you could store your guest data (guestId, postalCode, ...) in a separate table and make a classic inner join when querying your "audience" table (as you have the guestId when inserting into this table, you can reference it).
You may even use your existing read model class, with specialized methods (eg. insertAudience, insertGuest, ...). There's no need to make a separate read model for the guest table, IMO. Only advice would be to limit join within the read model (as in a single-table read model).

I will post two possible solutions for this in Prooph soon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions