Primitive Types
Describes how to deal with primitive field types from Cosmos to Domain
Primitive type fields are a one-to-one copy from Cosmos DB model into the Domain props.
Cosmos DB Model
lastName: string;
Domain Props
lastName: string;

Don't need id field on Domain Props side because already defined in EntityProps
Every field in domain props is required regardless of if it's optional on cosmos db side
Domain Entity Reference
export interface PhysicianEntityReference extends Readonly<PhysicianProps> {}
primitive types are copied automatically as read-only in entity reference
no need to omit primitive type fields from entity reference like you would for non-primitive type
if domain object only has primitive types, entity reference should look exactly as above
Domain Class
Primitive fields require getter and setter methods in the domain class of the object
Getter
get lastName() {
return this.props.lastName;
}
Setter
public requestSetLastName(lastName: string) {
this.props.lastName = lastName;
}
Domain Adapter
Primitive fields require getter and setter methods in the domain adapter of the object
Getter
get lastName() {
return this.doc.lastName;
}
Setter
set lastName(lastName) {
this.doc.lastName = lastName;
}
Last updated
Was this helpful?