Custom Types
Describes how to deal with a cosmos db fields of custom types local to that domain object
Cosmos DB Model
review?: MinicexReview;
Domain Props
readonly review: MinicexReviewProps;
Note: Custom types local to aggregate root like MinicexReview do not need a setRef method
Only need setRef for PopulatedDoc field types which refer to other aggregate roots not local to the domain object
Domain Entity Reference
export interface MinicexEntityReference
extends Readonly<
Omit<
MinicexProps,
"review"
>
> {
readonly review: MinicexReviewEntityReference;
}
Domain Class
Getter
get review(): MinicexReviewEntityReference {
return new MinicexReview(this.props.review, this.context);
}
Setter
Note: only need setter method if you have a setRef method for that field
Otherwise setting the props of the custom type is handled in that custom type's domain class
Domain Adapter
Getter
get review()
if (this.doc.review) {
return new MinicexReviewDomainAdapter(this.doc.review);
}
}
Setter
Note: no setter needed for custom types local to the aggregate root
Last updated
Was this helpful?