Skip to content

Custom Objects and Pointers to a CustomObject #287

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
buckettt opened this issue Nov 9, 2019 · 6 comments
Closed

Custom Objects and Pointers to a CustomObject #287

buckettt opened this issue Nov 9, 2019 · 6 comments

Comments

@buckettt
Copy link

buckettt commented Nov 9, 2019

I have a Custom Object (Activity) that I want to have a Pointer to another Custom Object (Spot).
I retrieve it as follows.

    queryBuilder = QueryBuilder<Activity>(Activity())
      ..orderByDescending("createdAt")
      ..includeObject([
        "mySpot", //this is the pointer
      ])

This works fine however mySpot is as a ParseObject whereas what I need is ParseObject as a CutomObject.

However when I setup my getter/setter for mySpot as a custom object as below

class Activity extends ParseObject implements ParseCloneable {
...
  static const String _keyTableName = 'Activity';
  static const String _keySpot = 'mySpot';
  
  Spot get myspot => get<Spot>(_keySpot) as Spot;
  set myspot(Spot s) => set<Spot>(_keySpot, s);
}

I get an error:
type 'ParseObject' is not a subtype of type 'Spot' in type cast

Whats the best way to cast a pointer to a custom object? Or is there a better way of doing this?

Edit: Spot extends ParseObject

@phillwiggins
Copy link
Member

phillwiggins commented Nov 10, 2019 via email

@buckettt
Copy link
Author

OK thanks, I guess that means it is impossible then?

@phillwiggins
Copy link
Member

phillwiggins commented Nov 10, 2019 via email

@buckettt
Copy link
Author

'mySpot' is just a pointer to a single object. I'm accessing it using the query above then simply doing:

var response = await queryBuilder.query();
if (response.success) {
    var a = response.results[0].myspot;

}

@phillwiggins
Copy link
Member

phillwiggins commented Nov 10, 2019 via email

@buckettt
Copy link
Author

No problem, thanks for your help.

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

No branches or pull requests

2 participants