mardi 26 janvier 2021

From a DDD perspective, how to handle DB specific types

I'm trying to implement DDD in my project and I'm using Firestore as my persistence infrastructure. Firestore in Go has some specific types like *firestore.DocumentRef.

I think that I should put it in my entity struct as it should represent my model, but my entity should also be db agnostic (I think).

So how should I handle from a DDD perspective this entity/struct:

type Holder struct {
    SocialReason       string                 `firestore:"social_reason" json:"social_reason"`
    Contact            value.Contact          `firestore:"contact" json:"contact"`
    Location           value.Location         `firestore:"location" json:"location"`
    SubmissionDatetime time.Time              `firestore:"submission_datetime" json:"-"`
    UpdateDatetime     time.Time              `firestore:"update_datetime" json:"-"`
    Status             string                 `firestore:"status" json:"status"`
    LastModifier       *firestore.DocumentRef `firestore:"last_modifier" json:"-"`
    CEP                string                 `firestore:"cep,omitempty" json:"cep,omitempty"`
    Country            string                 `firestore:"country" json:"country"`
    Region             string                 `firestore:"region,omitempty" json:"region,omitempty"`
    City               string                 `firestore:"city,omitempty" json:"city,omitempty"`
}

Aucun commentaire:

Enregistrer un commentaire