Skip to content
This repository was archived by the owner on Dec 14, 2022. It is now read-only.

Conversation

mkorenko
Copy link
Contributor

Currently it is not possible to make queries for nested object fields:

class Comment extends Entity {
  ...
  @field({ name: 'by' })
  by!: string;
}

@rootCollection({ name: 'posts' })
class Post extends Entity {
  ...
  @field({ name: 'pinnedComment' })
  pinnedComment!: Comment;
}
...
Collection(Post).query().where('pinnedComment.by', '==', 'userId').get();

Error: error TS2345: Argument of type '"pinnedComment.by"' is not assignable to parameter of type '... | "by" | "ref" | "toData"'.
The proposal is to optionally pass an array of properties as a path:

Collection(Post).query().where(['pinnedComment', 'by'], '==', 'userId').get();

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

Successfully merging this pull request may close these issues.

1 participant