Movatterモバイル変換


[0]ホーム

URL:


Objection.js

# Join Methods

# joinRelated()

queryBuilder= queryBuilder.joinRelated(relationExpression, opt);

Joins a set of relations described byrelationExpression. See the examples for more info.

# Arguments
ArgumentTypeDescription
relationExpressionRelationExpressionAn expression describing which relations to join.
optobjectOptional options. See the examples.
# Return value
TypeDescription
QueryBuilderthis query builder for chaining.
# Examples

Join one relation:

await Person.query().joinRelated('pets').where('pets.species','dog');

Give an alias for a single relation:

await Person.query().joinRelated('pets',{alias:'p'}).where('p.species','dog');

Join two relations:

await Person.query().joinRelated('[pets, parent]').where('pets.species','dog').where('parent.name','Arnold');

You can also use theobject notation

await Person.query().joinRelated({pets:true,parent:true}).where('pets.species','dog').where('parent.name','Arnold');

Join multiple nested relations. Note that when referring to nested relations: must be used as a separator instead of.. This limitation comes from the way knex parses table references.

await Person.query().select('persons.id','parent:parent.name as grandParentName').joinRelated('[pets, parent.[pets, parent]]').where('parent:pets.species','dog');

Give aliases for a bunch of relations:

await Person.query().select('persons.id','pr:pr.name as grandParentName').joinRelated('[pets, parent.[pets, parent]]',{aliases:{parent:'pr',pets:'pt'}}).where('pr:pt.species','dog');

You can also give aliases using the relation expression:

await Person.query().select('persons.id','pr:pr.name as grandParentName').joinRelated('[pets as pt, parent as pr.[pets as pt, parent as pr]]').where('pr:pt.species','dog');

# innerJoinRelated()

Alias forjoinRelated.

# outerJoinRelated()

Outer join version of thejoinRelated method.

# leftJoinRelated()

Left join version of thejoinRelated method.

# leftOuterJoinRelated()

Left outer join version of thejoinRelated method.

# rightJoinRelated()

Right join version of thejoinRelated method.

# rightOuterJoinRelated()

Left outer join version of thejoinRelated method.

# fullOuterJoinRelated()

Full outer join version of thejoinRelated method.

# join()

Seeknex documentation(opens new window)

# Return value
TypeDescription
QueryBuilderthis query builder for chaining.

# joinRaw()

Seeknex documentation(opens new window)

# Return value
TypeDescription
QueryBuilderthis query builder for chaining.

# innerJoin()

Seeknex documentation(opens new window)

# Return value
TypeDescription
QueryBuilderthis query builder for chaining.

# leftJoin()

Seeknex documentation(opens new window)

# Return value
TypeDescription
QueryBuilderthis query builder for chaining.

# leftOuterJoin()

Seeknex documentation(opens new window)

# Return value
TypeDescription
QueryBuilderthis query builder for chaining.

# rightJoin()

Seeknex documentation(opens new window)

# Return value
TypeDescription
QueryBuilderthis query builder for chaining.

# rightOuterJoin()

Seeknex documentation(opens new window)

# Return value
TypeDescription
QueryBuilderthis query builder for chaining.

# outerJoin()

Seeknex documentation(opens new window)

# Return value
TypeDescription
QueryBuilderthis query builder for chaining.

# fullOuterJoin()

Seeknex documentation(opens new window)

# Return value
TypeDescription
QueryBuilderthis query builder for chaining.

# crossJoin()

Seeknex documentation(opens new window)

# Return value
TypeDescription
QueryBuilderthis query builder for chaining.

Eager Loading Methods Other Methods


[8]ページ先頭

©2009-2025 Movatter.jp