packages/udaru-core/lib/ops/organizationOps.js
function replaceOrganizationPolicies (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const { id, policies } = params
      const tasks = [
        (job, next) => {
          Joi.validate({ id, policies }, validationRules.replaceOrganizationPolicies, (err) => {
            if (err) return next(Boom.badRequest(err))
            next()
          })
        },
        (job, next) => {
          job.id = id
          job.policies = utils.preparePolicies(policies)

          next()
        },
        checkOrg,
        clearOrganizationAttachedPolicies
      ]

      if (policies.length > 0) {
        tasks.push((job, next) => {
          utils.checkPoliciesOrg(job.client, job.policies, job.id, next)
        })
        tasks.push(insertOrgPolicies)
      }

      db.withTransaction(tasks, (err, res) => {
        if (err) return cb(err)

        organizationOps.readById(id, cb)
      })

      return promise
    }
function replaceOrganizationPolicies (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const { id, policies } = params
      const tasks = [
        (job, next) => {
          Joi.validate({ id, policies }, validationRules.replaceOrganizationPolicies, (err) => {
            if (err) return next(Boom.badRequest(err))
            next()
          })
        },
        (job, next) => {
          job.id = id
          job.policies = utils.preparePolicies(policies)

          next()
        },
        checkOrg,
        clearOrganizationAttachedPolicies
      ]

      if (policies.length > 0) {
        tasks.push((job, next) => {
          utils.checkPoliciesOrg(job.client, job.policies, job.id, next)
        })
        tasks.push(insertOrgPolicies)
      }

      db.withTransaction(tasks, (err, res) => {
        if (err) return cb(err)

        organizationOps.readById(id, cb)
      })

      return promise
    }
function replaceOrganizationPolicies ( params , cb ) { let promise = null if ( typeof cb !== 'function' ) [ promise , cb ] = asyncify ( ) const { id , policies } = params const tasks = [ ( job , next ) => { Joi . validate ( { id , policies } , validationRules . replaceOrganizationPolicies , ( err ) => { if ( err ) return next ( Boom . badRequest ( err ) ) next ( ) } ) } , ( job , next ) => { job . id = id job . policies = utils . preparePolicies ( policies ) next ( ) } , checkOrg , clearOrganizationAttachedPolicies ] if ( policies . length > 0 ) { tasks . push ( ( job , next ) => { utils . checkPoliciesOrg ( job . client , job . policies , job . id , next ) } ) tasks . push ( insertOrgPolicies ) } db . withTransaction ( tasks , ( err , res ) => { if ( err ) return cb ( err ) organizationOps . readById ( id , cb ) } ) return promise }
Replace organization policies

@param  {Object}   params { id, policies }
@param  {Function} cb
Replace organization policies