Mongolid\Model\Relations::referencesMany PHP Метод

referencesMany() защищенный Метод

Returns the cursor for the referenced documents as objects.
protected referencesMany ( string $entity, string $field ) : array
$entity string Class of the entity or of the schema of the entity.
$field string The field where the _ids are stored.
Результат array
    protected function referencesMany(string $entity, string $field)
    {
        $referencedIds = (array) $this->{$field};
        if (ObjectIdUtils::isObjectId($referencedIds[0] ?? '')) {
            foreach ($referencedIds as $key => $value) {
                $referencedIds[$key] = new ObjectID($value);
            }
        }
        $query = ['_id' => ['$in' => array_values($referencedIds)]];
        $entityInstance = Ioc::make($entity);
        if ($entityInstance instanceof Schema) {
            $dataMapper = Ioc::make(DataMapper::class);
            $dataMapper->setSchema($entityInstance);
            return $dataMapper->where($query, [], true);
        }
        return $entityInstance::where($query, [], true);
    }