Skip to content

Feature/repository if helpers

Pavlo Mashliakovskiy requested to merge feature/repositoryIfHelpers into master
  • helper Repository.attrsIf()
    let isPessimisticLock = !!UB.connection.domain.get('uba_user').attributes.mi_modifyDate
    // with whereIf
    let repo = UB.Repository('uba_user').attrs('ID').attrsIf(isPessimisticLock, 'mi_modifyDate')
    //without whereIf
    let repo = UB.Repository('uba_user').attrs('ID')
    if (isPessimisticLock) repo = repo.attrs('mi_modifyDate')  
  • helper Repository.whereIf()
    let filterString = 'foundAllLikeThis' // or may be empty string
    // with whereIf
    let repo = UB.Repository('my_entity').attrs('ID')
      .whereIf(filterString, 'myAttr', 'like', filterString)
    
    //without whereIf
    let repo = UB.Repository('my_entity').attrs('ID')
    if (filterString) repo = repo.where('myAttr', 'like', filterString)

Merge request reports

Loading