JSPM

  • Created
  • Published
  • Downloads 1483
  • Score
    100M100P100Q93603F
  • License MIT

simple module to help build Domain-Driven Design

Package Exports

  • base-domain

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (base-domain) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

base-domain

simple module to help build Domain-Driven Design"

concept

installation

$ npm install base-domain

usage

model definition

# {domain-dir}/hospital.coffee
class Hospital extends require('base-domain').Entity

    # property types
    @properties:
        name         : @TYPES.STRING
        address      : @TYPES.STRING
        beds         : @TYPES.NUMBER
        registeredAt : @TYPES.DATE
        isValidated  : @TYPES.BOOLEAN
        doctors      : @TYPES.MODELS 'doctor'

module.exports = Hospital

factory definition

# {domain-dir}/hospital-factory.coffee
class HospitalFactory extends require('base-domain').BaseFactory

    @modelName: 'hospital'

module.exports = HospitalFactory

repository definition

# {domain-dir}/hospital-repository.coffee
class HospitalRepository extends require('base-domain').BaseRepository

    @modelName: 'hospital'

module.exports = HospitalRepository

use them by facade

domain = require('base-domain').createInstance
    dirname: '/path/to/domain-dir'


Hospital = domain.getModel('hospital')
hospitalFactory = domain.createFactory('hospital')
hospitalRepository = domain.createRepository('hospital')

hospitalRepository.find(where: name: 'CureApp Hp.').then (hospitals)->
    console.log hospitals