Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to eager-load related edges/vertices? #40

Open
CristianSitov opened this issue Jul 8, 2017 · 2 comments
Open

How to eager-load related edges/vertices? #40

CristianSitov opened this issue Jul 8, 2017 · 2 comments

Comments

@CristianSitov
Copy link

By running simple queries with Model::find() or Model::where() I'm obtaining a collection with entities only, without the related objects/vertices.

"@type" => "d"
"@rid" => "#25:1"
"@version" => 3
"@class" => "Resources"
"uuid" => "116118d0-63d3-11e7-9fdd-4d775a1245c6"
"updated_at" => "2017-07-08 11:46:23"
"created_at" => "2017-07-08 11:46:23"
"out_has_classification_types" => array:1 [
  0 => "#42:0"
]
"out_has_notes" => array:1 [
  0 => "#39:0"
]
"@fieldTypes" => "updated_at=t,created_at=t,out_has_classification_types=g,out_has_notes=g"

How can I run a query that can pull a specific "branch", for eg., Resource > HasClassificationType > ClassificationType and Resource > HasNote > Description, all together?

@CristianSitov
Copy link
Author

If I setup a relation like

public function hasClassificationType()
{
    return $this->hasOne(ResourceClassificationType::class, HasClassificationType::class);
}

then I get the following error

Type error: Argument 1 passed to Sgpatil\Orientdb\Query\Builder::modelAsNode() must be of the type array or null, string given, called in /vendor/sgpatil/oriquent/src/Sgpatil/Orientdb/Eloquent/Relations/HasOne.php on line 69

@CristianSitov
Copy link
Author

CristianSitov commented Jul 8, 2017

The problem seems to be here:

// in Sgpatil/Orientdb/Eloquent/Relations/HasOne.php
$parentNode = $this->query->getQuery()->modelAsNode($this->parent->getTable());

while Query::modelAsNode() method says it only accepts arrays as seen here

 /* @param  array $labels
 * @return string
 */
public function modelAsNode(array $labels = null) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant