8000 filtering through a HasMany relationship -> "owner.buildFindQuery is not a function" · Issue #53 · Vincit/objection-find · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
filtering through a HasMany relationship -> "owner.buildFindQuery is not a function" #53
Open
@leearaneta

Description

@leearaneta

hi,

i'm trying to do something very similar to an example in the docs:

// This checks if the relation `children` contains at least
// one person whose age is less than 10.
'children.age:lt': 10,
...

i'm getting an error that looks like this:

TypeError: owner.buildFindQuery is not a function
    at HasManyRelation.findQuery (/app/backend/node_modules/objection/lib/relations/Relation.js:118:11)
    at PropertyRef.buildFilter (/app/backend/node_modules/objection-find/lib/PropertyRef.js:145:28)
...

i dug into the code for both objection-find and objection and one of the function signatures doesn't seem to be consistent.

here's where the error is in objection-find:

const subQuery = rel.findQuery(rel.relatedModelClass.query(), {
  ownerIds: rel.ownerProp.refs(builder)
});

and here's the findQuery function as defined in objection:

findQuery(builder, owner) {
  const relatedRefs = this.relatedProp.refs(builder);
  owner.buildFindQuery(builder, this, relatedRefs);

  return this.applyModify(builder);
}

it looks like findQuery should take in a RelationOwner as its second argument, but we're passing in the relatedRefs instead. i'm not sure how to retrieve the owner - any help would be appreciated!

here are my query parameters for context:

{
    eager: '[account,assignments,users]',
    'assignments.userId:eq': 1,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0