Skip to content

Instantly share code, notes, and snippets.

@AntonStoeckl
Created May 4, 2020 14:37
Show Gist options
  • Save AntonStoeckl/63b6c805b67760d2e2ee080d7cf1f82d to your computer and use it in GitHub Desktop.
Save AntonStoeckl/63b6c805b67760d2e2ee080d7cf1f82d to your computer and use it in GitHub Desktop.
Example for my iDDD with Go blog article series at https://medium.com/@TonyBologni
package customer
import (
"github.com/AntonStoeckl/go-iddd/service/shared/es"
)
type View struct {
ID string
EmailAddress string
IsEmailAddressConfirmed bool
GivenName string
FamilyName string
IsDeleted bool
Version uint
}
func BuildViewFrom(eventStream es.EventStream) View {
customer := buildCurrentStateFrom(eventStream)
customerView := View{
ID: customer.id.String(),
EmailAddress: customer.emailAddress.String(),
IsEmailAddressConfirmed: customer.isEmailAddressConfirmed,
GivenName: customer.personName.GivenName(),
FamilyName: customer.personName.FamilyName(),
IsDeleted: customer.isDeleted,
Version: customer.currentStreamVersion,
}
return customerView
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment