🔏
Azure Serverless Quickstart
  • Introduction
  • Initial Setup
    • Workstation Installs
    • Codebase
      • Directory Structure
      • User Interface Project
        • Configuring StoryBook
        • Configure Tailwind
        • Configure Craco
        • -Architectural Decision Log
      • Data Access Project
        • DDD
      • Untitled
      • Full Stack Debugging
      • Creating GitHub Project
    • Infrastructure
      • Configure Session Behavior
      • Create AAD Tenant
      • Resource Group
      • Create AAD B2C Instance
        • Identity Experience Framework
        • Configure Session Behavior
      • Storage Account & CDN
        • CDN Rules
        • Configure Azure BLOB Storage
      • App Insights
        • Create AppInsight Account
        • Apollo GraphQL App Insights Configuration
      • CosmosDB
      • Twilio SendGrid
      • KeyVault
      • Function
      • Function App Settings
      • Front Door
      • DevOps
      • Optional Items
        • Azure Data Factory
      • Azure Event Hub
    • CICD and Source Control
      • Azure DevOps
      • SonarCloud
        • Incorporate into Yaml
      • Chromatic
      • User Interface YAML
      • CICD for Data Access
        • Create Pipeline
        • Data Access YAML
  • Application Structure
    • Connect Apollo
      • Apollo Overview
      • Create Apollo Component
    • MongoDB Integration
      • Mappings
      • Directory Structure
      • Apollo Connection
      • Models
      • Queries Mutations and Subscriptions
      • Caching Reponses
    • Integrating GraphQL Tools
      • GraphQL Code Generator
    • Feature Flags
      • Flag Structure & Storage
      • Website Integration
      • Apollo Integration
      • Tips and Techniques
      • Alternative Approaches
    • React Router
    • Adding Authentication
      • Create AAD Applications
      • Configure AAD For External Identities
      • Adding MSAL And React
      • Add MSAL to the build
      • Add MSAL to ApolloClient
      • Add MSAL to ApolloServer
    • Ant Design
    • Jest Tests
  • Azure Active Directory Business-to-Consumer (AD B2C)
    • Introduction
    • How to navigate through AD B2C documentation
    • Localization
    • Abbreviations
    • Azure AD B2C Extension
  • Cognitive Search
  • Cost Analysis
  • Technical Architecture
    • Identity and Access Control
  • Adding Functionality
    • Google Analytics
      • Create Analytics
    • DAPR
      • DAPR setup
      • DAPR Services (ignore for now)
        • Identity
  • Patterns and Practices
    • Idempotent Messages
    • Pathways
    • DDD
      • Initial Setup
        • Aggregate Root
        • Entity
        • Value Object
      • Field Types
        • Primitive Types
        • Non-Primitive Types
          • Types.DocumentArray
          • PopulatedDoc
          • Custom Types
      • Example Walkthrough
  • Open Items
    • Issue Tracking
  • Helpful Resources
  • DDD
    • Page 1
  • Experimental
    • StaticWebApp
    • Azure Maps
Powered by GitBook
On this page
  • Cosmos DB Model
  • Domain Props
  • Domain Entity Reference
  • Domain Class
  • Domain Adapter

Was this helpful?

  1. Patterns and Practices
  2. DDD
  3. Field Types
  4. Non-Primitive Types

PopulatedDoc

Describes how to deal with a cosmos db field type of PopulatedDoc

Cosmos DB Model

/infrastructure/data-sources/cosmos-db/models/physician.ts
updatedBy: PopulatedDoc<Account>;

Domain Props

/domain/contexts/physician/physician.ts
readonly updatedBy: AccountProps;
setUpdatedByRef: (updatedBy: AccountEntityReference) => void;
  • Every PopulatedDoc field needs the read-only field with props type and a setRef field which is a method that takes in an entity reference of the domain object referenced in previous field

  • The argument of setRef method should be the same as the name of the field above it

Domain Entity Reference

/domain/contexts/physician/physician.ts
export interface PhysicianEntityReference 
extends Readonly<
    Omit<
        PhysicianProps,
        "updatedBy" | "setUpdatedByRef"
        >
    > {
    readonly updatedBy: AccountEntityReference;
}
  • Note: must include field name and setRef method name in the omit union of strings

Domain Class

Getter

/domain/contexts/physician/physician.ts
get updatedBy(): AccountEntityReference {
    return new Account(this.props.updatedBy, this.context);
}

Setter

/domain/contexts/physician/physician.ts
public requestSetUpdatedBy(updatedBy: AccountEntityReference) {
    this.setUpdatedByRef(updatedBy);
}
  • setRef method comes from field defined in Domain Props

  • Note: setRef method takes in entity reference of domain object as an argument

Domain Adapter

Getter

/domain/infrastructure/persistence/physician.domain-adapter.ts
get updatedBy(): AccountProps {
    if (this.doc.updatedBy) {
        return new AccountDomainAdapter(this.doc.updatedBy);
    }
}

Setter

/domain/infrastructure/persistence/physician.domain-adapter.ts
setUpdatedByRef(updatedBy: AccountEntityReference) {
    this.doc.set("updatedBy", updatedBy["props"]["doc"]);
}
  • Needs a setter for the setRef method created in domain props

  • takes in entity reference of domain object being stored in that field

  • Note: use exactly the notation below for setting the doc: first argument is the field name as a string and the second is the argument being passed in to the function with square bracket notation accessing the doc of that domain object

PreviousTypes.DocumentArrayNextCustom Types

Last updated 2 years ago

Was this helpful?