Skip to content

Check attributes spelling when using multi level includes #1368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
frouo opened this issue May 24, 2021 · 3 comments · Fixed by #2491
Closed

Check attributes spelling when using multi level includes #1368

frouo opened this issue May 24, 2021 · 3 comments · Fixed by #2491
Labels
state:released Released as stable version state:released-alpha Released as alpha version

Comments

@frouo
Copy link

frouo commented May 24, 2021

Is your feature request related to a problem? Please describe

I use Typescript and I could not find a way to check object's attributes when using multi level includes.

One level include works very fine (as shown below), but what if we use multi level?

Describe the solution you'd like

Having a static pass-through function that returns the attribute:

attr<K extends Extract<keyof T, string>>(attr: K): K;

Usage could be like

  .include(`${Comment.attr("post")}.${Post.attr("author")}`)

or

  .include(`${Attributes<Comment>.get("post")}.${Attributes<Post>.get("author")}`)

Note: I don't pretend to be a Typescript expert so may consider the above suggestions as pseudo-code.

Additional context

export class Comment extends Parse.Object<{
  post: Post;
  text: string;
}> {
  constructor(options?: any) {
    super("Comment", options);
  }
}

export class Post extends Parse.Object<{
  author: Parse.User;
}> {
  constructor(options?: any) {
    super("Post", options);
  }
}

export async function getComments() {
  return await new Parse.Query(Comment)
    .include("post") // here Typescript works very well, it checks for Comment's attributes: include(...key: ("post" | "text" | keyof Parse.BaseAttributes)[]): Parse.Query<Comment>
    .include("post.author") // here Typescript underlines red
    .find();
}

Screenshots

Capture d’écran 2021-05-24 à 13 25 44

Capture d’écran 2021-05-24 à 13 24 44

Thank you

@stale
Copy link

stale bot commented Jul 21, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 6.1.0-alpha.3

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Mar 16, 2025
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 6.1.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-alpha Released as alpha version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants