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

feat(query): add ability to pass property path array to where() and orderBy() methods#6

Open
mkorenko wants to merge 1 commit into
lmcq:masterfrom
mkorenko:query-methods-prop-path
Open

feat(query): add ability to pass property path array to where() and orderBy() methods#6
mkorenko wants to merge 1 commit into
lmcq:masterfrom
mkorenko:query-methods-prop-path

Conversation

@mkorenko

Copy link
Copy Markdown
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