@param array $records
@param mixed $include
@param mixed $id_field
@param bool  $use_doc If true, only the document is cleaned

@return array
968273
protected static function cleanRecords(
        $records,
        $include = '*',
        $id_field = self::DEFAULT_ID_FIELD,
        $use_doc = false
    ){
        $out = [];

        foreach ($records as $record) {
            if ($use_doc) {
                $record = array_get($record, 'doc', $record);
            }

            $out[] = '*' == $include ? $record : static::cleanRecord($record, $include, static::DEFAULT_ID_FIELD);
        }

        return $out;
    }
20260
public function get($appId, $recordId, $order = 'desc', $offset = 0, $limit = 10, $guestSpaceId = null): array
    {
        $options = ['json' => [
            'app' => $appId,
            'record' => $recordId,
            'order' => $order,
            'offset' => $offset,
            'limit' => $limit
        ]];

        /** @var JsonStream $stream */
        $stream = $this->client
            ->get(KintoneApi::generateUrl('record/comments.json', $guestSpaceId), $options)
            ->getBody();

        return $stream->jsonSerialize()['comments'];
    }
36058
def getFilteredRecords( dbid, fieldNames, query = nil, qid = nil, qname = nil, clist = nil, slist = nil, fmt = "structured", options = nil )
      filteredRecords = []
      iterateFilteredRecords(dbid, fieldNames, query, qid, qname, clist, slist, fmt, options){ |filteredRecord| 
         filteredRecords << filteredRecord 
      }
      filteredRecords
   end
232828
def getRecords(rids, dbid = @dbid, fieldNames = nil)
      records = []
      if rids.length > 0
        query = ""
        rids.each{|rid| query << "{'3'.EX.'#{rid}'}OR"}
        query[-2] = "" 
        fieldNames ||= getFieldNames(dbid)
        iterateRecords(dbid,fieldNames,query){|r| records << r }
      end
      if block_given?
        records.each{|rec|yield rec}
      else
        records  
      end        
   end
438779
public function get_document($record, $options = array()) {
        global $CFG;
        require_once($CFG->dirroot . '/course/lib.php');

        // Get the context, modinfo, and section.
        try {
            $context = \context_course::instance($record->course);
        } catch (\moodle_exception $ex) {
            // Notify it as we run here as admin, we should see everything.
            debugging('Error retrieving ' . $this->areaid . ' ' . $record->id .
                    ' document, not all required data is available: ' . $ex->getMessage(),
                    DEBUG_DEVELOPER);
            return false;
        }

        // Title - use default if none given.
        $title = get_section_name($record->course, $record->section);

        // Prepare associative array with data from DB.
        $doc = \core_search\document_factory::instance($record->id, $this->componentname, $this->areaname);
        $doc->set('title', content_to_text($title, false));
        $doc->set('content', content_to_text($record->summary, $record->summaryformat));
        $doc->set('contextid', $context->id);
        $doc->set('courseid', $record->course);
        $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
        $doc->set('modified', $record->timemodified);

        return $doc;
    }
448898
public function processRecords(Entity $entity, array $with, $records, $readOnly)
    {
        $pkField = $entity->getPrimaryKey();

        $objects          = [];
        $currentKey       = null;
        $object           = null;
        $recordsToProcess = [];

        $relations = array_map(
            [$entity, 'getRelation'],
            array_intersect($with, $entity->getRelationNames())
        );

        foreach ($records as $record) {
            //Extract columns that are relevant for the current metadata
            $key = $record[ $pkField ];
            if ($currentKey !== $key) {
                if ($object !== null) {
                    //Process and save the previous object
                    $this->processRelated(
                        $entity,
                        $object,
                        $readOnly,
                        $recordsToProcess,
                        $relations,
                        $with
                    );
                    $recordsToProcess       = [];
                    $objects[ $currentKey ] = $object;
                }
                $currentKey = $key;
                $object     = $this->createObject(
                    $entity,
                    $record,
                    $relations,
                    $readOnly
                );
            }
            //Store the record to be processed for the related entities
            $recordsToProcess[] = $record;
        }
        if ($object !== null) {
            //Process and save the last object
            $this->processRelated(
                $entity,
                $object,
                $readOnly,
                $recordsToProcess,
                $relations,
                $with
            );
            $objects[ $key ] = $object;
        }

        return $objects;
    }
68736
public function getAllUsers($include_docs = false)
	{
		$client = new CouchClient($this->client->dsn(), $this->usersdb, $this->client->options());
		if ($include_docs) {
			$client->include_docs(true);
		}
		return $client->startkey("org.couchdb.user:")->endkey("org.couchdb.user?")->getAllDocs()->rows;
	}
1038835
def records(options={})
      options["sortField"], options["sortDirection"] = options.delete(:sort) if options[:sort]
      results = self.class.get(worksheet_url, query: options).parsed_response
      check_and_raise_error(results)
      RecordSet.new(results)
    end
758885
public function editRecordSharing(Request $request, $base_id, $record_id)
    {

        $record = new \record_adapter($this->app, \phrasea::sbasFromBas($this->app, $base_id), $record_id);
        $subdefName = (string)$request->request->get('name');
        $state = $request->request->get('state') == 'true' ? true : false;

        $acl = $this->getAclForUser();
        if (!$acl->has_right(\ACL::BAS_CHUPUB)
            || !$acl->has_right_on_base($record->getBaseId(), \ACL::CANMODIFRECORD)
            || !$acl->has_right_on_base($record->getBaseId(), \ACL::IMGTOOLS)
            || ('document' == $subdefName && !$acl->has_right_on_base($record->getBaseId(), \ACL::CANDWNLDHD))
            || ('document' != $subdefName && !$acl->has_access_to_subdef($record, $subdefName))
        ) {
            $this->app->abort(403);
        }

        $subdef = $record->get_subdef($subdefName);

        if (null === $permalink = $subdef->get_permalink()) {
            return $this->app->json(['success' => false, 'state' => false], 400);
        }

        try {
            $permalink->set_is_activated($state);
            $return = ['success' => true, 'state' => $permalink->get_is_activated()];
        } catch (\Exception $e) {
            $return = ['success' => false, 'state' => $permalink->get_is_activated()];
        }

        return $this->app->json($return);
    }
1228876
public function convert($records): DOMDocument
    {
        if (!is_iterable($records)) {
            throw new TypeError(sprintf('%s() expects argument passed to be iterable, %s given', __METHOD__, gettype($records)));
        }

        $field_encoder = $this->encoder['field']['' !== $this->column_attr];
        $record_encoder = $this->encoder['record']['' !== $this->offset_attr];
        $doc = new DOMDocument('1.0');
        $root = $doc->createElement($this->root_name);
        foreach ($records as $offset => $record) {
            $node = $this->$record_encoder($doc, $record, $field_encoder, $offset);
            $root->appendChild($node);
        }
        $doc->appendChild($root);

        return $doc;
    }
792488
public function import(array $definitions, array $records, array $defaultAttributes = [], $persist = true): array
    {
        $imported = [];
        $recordsByHandle = $this->getRecordsByHandle($records);
        foreach ($definitions as $handle => $definition) {
            $modelClass = $definition['class'];
            $converter = Craft::$app->controller->module->getConverter($modelClass);
            if ($converter) {
                $record = $this->findOrNewRecord($recordsByHandle, $definition, $handle);

                if ($converter->getRecordDefinition($record) === $definition) {
                    Schematic::info('- Skipping '.get_class($record).' '.$handle);
                } else {
                    $converter->setRecordAttributes($record, $definition, $defaultAttributes);
                    if ($persist) {
                        Schematic::info('- Saving '.get_class($record).' '.$handle);
                        if (!$converter->saveRecord($record, $definition)) {
                            Schematic::importError($record, $handle);
                        }
                    }
                }

                $imported[] = $record;
            }
            unset($recordsByHandle[$handle]);
        }

        if (Schematic::$force && $persist) {
            // Delete records not in definitions
            foreach ($recordsByHandle as $handle => $record) {
                $modelClass = get_class($record);
                Schematic::info('- Deleting '.get_class($record).' '.$handle);
                $converter = Craft::$app->controller->module->getConverter($modelClass);
                $converter->deleteRecord($record);
            }
        }

        return $imported;
    }
190002
def editRecords(dbid,fieldValuesToSet,query=nil,qid=nil,qname=nil)
      edited_rids = []
      if fieldValuesToSet and fieldValuesToSet.is_a?(Hash)
         verifyFieldList(fieldValuesToSet.keys,nil,dbid)
         recordIDs = getAllValuesForFields(dbid,["3"],query,qid,qname,"3")
         if recordIDs
            numRecords = recordIDs["3"].length
            (0..(numRecords-1)).each {|i|
               @rid = recordIDs["3"][i]
               setFieldValues(fieldValuesToSet)
               edited_rids << @rid
            }   
         end
      else
         raise "'fieldValuesToSet' must be a Hash of field names and values."
      end
      edited_rids 
   end
224639
private function listRecordStatus(\record_adapter $record)
    {
        $ret = [];
        foreach ($record->getStatusStructure() as $bit => $status) {
            $ret[] = [
                'bit'   => $bit,
                'state' => \databox_status::bitIsSet($record->getStatusBitField(), $bit),
            ];
        }

        return $ret;
    }
493958
public function get_fields(array $grep_fields = null, $includeBusiness = false)
    {
        $fields = [];

        foreach ($this->retrieve_fields() as $meta_struct_id => $field) {
            if ($grep_fields && ! in_array($field->get_name(), $grep_fields, true)) {
                continue;
            }

            if ((!$includeBusiness) && $field->get_databox_field()->isBusiness() === true) {
                continue;
            }

            $fields[] = $field;
        }

        return $fields;
    }
1081151
private function updateRecordStatus($id, $recordStatus, $method)
    {
        $sets[ 'record_status' ] = $recordStatus;
        $primaryKey = isset($this->primaryKey) ? $this->primaryKey : 'id';

        if (method_exists($this, 'updateRecordSets')) {
            $this->updateRecordSets($sets);
        }

        if (method_exists($this, $beforeMethod = 'before' . ucfirst($method))) {
            call_user_func_array([&$this, $beforeMethod], [$sets]);
        }

        if ($this->qb->table($this->table)->limit(1)->update($sets, [$primaryKey => $id])) {
            if (method_exists($this, $afterMethod = 'after' . ucfirst($method))) {
                return call_user_func([&$this, $beforeMethod]);
            }

            return true;
        }

        return false;
    }
8586
private function getClassesForCommitAction(array $documents, bool $includeEmbedded = false) : array
    {
        if (empty($documents)) {
            return [];
        }
        $divided = [];
        $embeds  = [];
        foreach ($documents as $oid => $d) {
            $className = get_class($d);
            if (isset($embeds[$className])) {
                continue;
            }
            if (isset($divided[$className])) {
                $divided[$className][1][$oid] = $d;
                continue;
            }
            $class = $this->dm->getClassMetadata($className);
            if ($class->isEmbeddedDocument && ! $includeEmbedded) {
                $embeds[$className] = true;
                continue;
            }
            if (empty($divided[$class->name])) {
                $divided[$class->name] = [$class, [$oid => $d]];
            } else {
                $divided[$class->name][1][$oid] = $d;
            }
        }
        return $divided;
    }
1302091
protected function getRecordPageId($status, $recordTable, $recordUid, $originalUid, array $fields, DataHandler $tceMain)
    {
        if ($recordTable === 'pages' && isset($fields['l10n_parent']) && intval($fields['l10n_parent']) > 0) {
            return $fields['l10n_parent'];
        }

        if ($status === 'update' && !isset($fields['pid'])) {
            $recordPageId = $this->getValidatedPid($tceMain, $recordTable, $recordUid);
            if (($recordTable === 'pages') && ($this->rootPageResolver->getIsRootPageId($recordUid))) {
                $recordPageId = $originalUid;
            }

            return $recordPageId;
        }

        return $fields['pid'];
    }