Types.DocumentArray
Describes how to deal with a cosmos db field type of Types.DocumentArray
Cosmos DB Model
licenses: Types.DocumentArray<PhysicianLicense>;
Domain Props
readonly licenses: PropArray<PhysicianLicenseProps>;
Domain Entity Reference
export interface PhysicianEntityReference
extends Readonly<
Omit<
PhysicianProps,
"licenses"
>
> {
readonly licenses: ReadonlyArray<PhysicianLicenseEntityReference>;
}
Domain Class
Getter
get licenses(): ReadonlyArray<PhysicianLicenseEntityReference> {
return this.props.licenses.items.map(
(license) => new PhysicianLicense(license, this.context)
);
}
Setter
No setter for domain objects local to the aggregate root (Entity or ValueObject)
Only need setRef method for PopulatedDoc type fields
Domain Adapter
Getter
get licenses() {
if (this.doc.licenses) {
return new MongoosePropArray(this.doc.licenses, PhysicianLicenseDomainAdapter);
}
}
Note: PhysicianLicenseDomainAdapter should exist in same file as PhysicianDomainAdapter
Setter
No setter for Types.DocumentArray type fields
Wil be handled in domain adapter for that domain context, PhysicianLicenseDomainAdapter
Last updated
Was this helpful?