Fetch data for an organization

@param  {String}   id
@param  {Function} cb
764653
function readById (id, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      let organization
      const tasks = []

      tasks.push((next) => {
        Joi.validate(id, validationRules.readById, (err) => {
          if (err) return next(Boom.badRequest(err))
          next()
        })
      })

      tasks.push((next) => {
        const sqlQuery = SQL`
          SELECT *
          FROM organizations
          WHERE id = ${id}
        `
        db.query(sqlQuery, (err, result) => {
          if (err) return next(Boom.badImplementation(err))
          if (result.rowCount === 0) return next(Boom.notFound(`Organization ${id} not found`))

          organization = mapping.organization(result.rows[0])
          next()
        })
      })

      tasks.push((next) => {
        const sqlQuery = SQL`
          SELECT pol.id, pol.name, pol.version, org_pol.variables, org_pol.policy_instance
          FROM organization_policies org_pol, policies pol
          WHERE org_pol.org_id = ${id} AND org_pol.policy_id = pol.id
          ORDER BY UPPER(pol.name)
        `
        db.query(sqlQuery, (err, result) => {
          if (err) return next(Boom.badImplementation(err))

          organization.policies = result.rows.map(mapping.policy.simple)
          next()
        })
      })

      async.series(tasks, (err) => {
        if (err) return cb(err)

        return cb(null, organization)
      })

      return promise
    }
1188091
static function fetch( $id, $asObject = true, $status = eZRSSExport::STATUS_VALID )
    {
        return eZPersistentObject::fetchObject( eZRSSExportItem::definition(),
                                                null,
                                                array( "id" => $id,
                                                       'status' => $status ),
                                                $asObject );
    }
492187
static function fetchByObjectAttributeID( $id, $contentobjectAttributeID, $asObject = true )
    {
        return eZPersistentObject::fetchObject( eZInformationCollectionAttribute::definition(),
                                                null,
                                                array( 'informationcollection_id' => $id,
                                                       'contentobject_attribute_id' => $contentobjectAttributeID ),
                                                $asObject );
    }
195350
function(collection, options, cb) {
    var ids = [];
    var keys = _.isFunction(collection.url) ? collection.url() : collection.url;
    keys += options.keys;
    debug('findKeys', keys);
    this.store().getItem(keys, function(err, data) {
      if (data) ids.push(keys);
      cb(null, ids);
    });
  }
1328635
function findById(id, cb) {
  db.getClient(function(err, client, done) {
    client.query(SELECT_ID, [id], function(err, r) {
      var result = r && r.rows[0];
      if(!err && !result) err = new exceptions.NotFound();
      if(err) {
        cb(err);
        done(err);
      } else {
        cb(null, result);
        done();
      }
    });
  });
}
1186855
function obtainInfo(id, action, cb) {
    request.get({
        url: action,
        timeout: 10000,
        maxAttempts: 2
    }, function (error, response, body) {
        if (error || response.statusCode != 200) {
            cb(utils.errorDown())
            return
        }

        const data = JSON.parse(body)
        if (data.errors != undefined) {
            cb(utils.errorNoData())
            return
        }

        let entity = null
        try {
            entity = createTrackerEntity(data)
        } catch (error) {
            return cb(utils.errorParser(id, error.message))
        }

        if(entity != null) cb(null, entity)
    })
}
1161356
public function getRawContent($cb, $uid, $byUid = true)
    {
        $this->onResponse->push($cb);
        $this->fetch(['FLAGS', 'RFC822.TEXT'], $uid, null, $byUid, self::TAG_GETRAWCONTENT);
    }
1290344
function obtainInfo(action, id, cb) {
    request.post({
        url: action,
        form: {
            shippingNumber: id
        },
        timeout: 10000
    }, function (error, response, body) {
        if (error || response.statusCode != 200) {
            cb(utils.errorDown())
            return
        }

        // Not found
        if (body.indexOf('errorMessage') != -1) {
            cb(utils.errorNoData())
            return
        }

        let entity = null
        try {
            entity = createCorreosEntity(body)
            entity.retries = response.attempts
        } catch (error) {
            return cb(utils.errorParser(id, error.message))
        }

        cb(null, entity)
    })
}
757671
function showPeople( id, callback ) {
    var url = apiBaseUrl+endpoints['people'] + id;

    fetch(url, function(result) {
        callback(result);
    });
}
1217171
function update (params, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const { id, name, description, metadata } = params

      Joi.validate({ id, name, description, metadata }, validationRules.update, (err) => {
        if (err) return cb(Boom.badRequest(err))

        const sqlQuery = SQL`
          UPDATE organizations
          SET
            name = ${name},
            description = ${description},
            metadata = ${metadata}
          WHERE id = ${id}
        `
        db.query(sqlQuery, function (err, result) {
          if (utils.isUniqueViolationError(err)) return cb(Boom.conflict(err.detail))
          if (err) return cb(Boom.badImplementation(err))
          if (result.rowCount === 0) return cb(Boom.notFound())

          organizationOps.readById(id, cb)
        })
      })

      return promise
    }
1103186
@SuppressWarnings("unchecked")
  public <C extends CDACallback<T>> C one(String id, C callback) {
    return (C) Callbacks.subscribeAsync(baseQuery().one(id), callback, client);
  }
1328587
static function fetch( $id, $asObject = true )
    {
        return eZPersistentObject::fetchObject( eZOrderStatus::definition(),
                                                null,
                                                array( "id" => $id ),
                                                $asObject );
    }
20521
function getId(id){
        if(_.isObject(id) && !_.isUndefined(id.id)){
            if (objectIdRegex.test(id.id)) {
                id = id.id;
            }
            else {
                id = null;
            }
        }
        return id;
    }
606431
function getStore(id, callback) {
  db.collection(stores, function(err, collection) {
    if(err) return callback(err);

    collection.findOne({ _id: BSON.ObjectID(id)}, function(err, store) {
      if (err) return callback(err);
      callback(null, store);
    });
  });
}
1213041
function readTeamUsers ({ id, page = 1, limit, organizationId }, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      Joi.validate({ id, page, limit, organizationId }, validationRules.readTeamUsers, function (err) {
        if (err) return cb(Boom.badRequest(err))

        const pageLimit = limit || _.get(config, 'authorization.defaultPageSize')
        const offset = (page - 1) * pageLimit

        const job = {
          id: id,
          organizationId: organizationId,
          offset: offset,
          limit: pageLimit,
          team: {},
          client: db
        }

        loadTeamUsers(job, (err) => {
          if (err) return cb(err)
          const pageSize = pageLimit || job.totalUsersCount
          const result = {
            page: page,
            limit: pageSize,
            total: job.totalUsersCount,
            data: job.team.users
          }
          return cb(null, result)
        })
      })

      return promise
    }
116478
function(peopleInProject, cb) {
      userIdsToCc = _.pluck(peopleInProject, 'id').join(',');
      exports.getProject(subdomain, username, passwordOrAPIToken, id, function(err, respData) {
        cb(err, respData);
      });
    }
567122
function deleteById (id, cb) {
      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const tasks = [
        (job, next) => {
          Joi.validate(id, validationRules.deleteById, (err) => {
            if (err) return next(Boom.badRequest(err))
            next()
          })
        },
        (job, next) => {
          job.id = id
          next()
        },
        fetchOrganizationUsers,
        removeUsersFromTeams,
        removeUsersPolicies,
        fetchOrganizationTeams,
        removeTeamsPolicies,
        clearOrganizationAttachedPolicies,
        deleteOrganizationPolicies,
        deleteOrganizationTeams,
        deleteOrganizationUsers,
        deleteOrganization
      ]

      db.withTransaction(tasks, cb)

      return promise
    }