I’m trying to query data from multiple collections but end up getting an error.
This is the query
let actors = Actors.byUserId("foo").pageSize(50)
let actor = actors.firstWhere(item => item.slug == "bar")
let projects = Projects.byActorId(actor.id)
{
actors: actors,
actor: actor,
projects: projects,
}
I also tried changing line 3
let projects = Projects.byActorId(actor?.id)
let projects = Projects.byActorId(actor!.id)
These are the errors I am getting for the various combinations
invalid_query
error: Type `Null` does not have field `id`
at *query*:4:27
|
4 | if (actor!= null && actor.id != null) {
| ^^
|
hint: Use the ! or ?. operator to handle the null case
|
4 | if (actor!= null && actor!.id != null) {
| +
|
error: Type `Null` does not have field `id`
at *query*:5:43
|
5 | let projects = Projects.byActorId(actor.id)
| ^^
|
hint: Use the ! or ?. operator to handle the null case
|
5 | let projects = Projects.byActorId(actor!.id)
| +
|
invalid_argument
error: invalid argument `term1`: Argument cannot be used as lookup term
at *query*:3:34
|
3 | let projects = Projects.byActorId(actor!.id)
| ^^^^^^^^^^^
|
invalid_argument
error: invalid argument `term1`: Argument cannot be used as lookup term
at *query*:3:34
|
3 | let projects = Projects.byActorId(actor?.id)
| ^^^^^^^^^^^
|