Parse Query Only Returning Pointers

I think I may be going crazy. Either that, or I’m doing something very obviously wrong and am completely missing it.

I’ve created a server using TypeScript, and I’ve defined a custom object by extending Parse.Object. I’ve also ensured that I am properly registering the subclass per the documentation. I am able to create instances of this object and save them like any other Parse object, and have verified they exist in the database, but when it comes to querying the objects, I’m having issues.

It doesn’t matter what way I attempt to query for objects, I always just get a pointer back, and not the full object. I have to subsequently call .fetch() on the items returned from the query in order to get the properties from it.

Am I doing something incorrectly here? Any help is greatly appreciated.

Thanks,

Rob

Here is some more information/code examples of how I’m defining everything.

Subclass:

export class Foo extends Parse.Object { 
    constructor() { 
        super("Foo");
    }
}

Registration:

import { Foo } from "./foo";

Parse.Object.registerSubclass("Foo", Foo);

Query:

import { Foo } from ("./foo"); 

const fooQuery = new Parse.Query(Foo);
const foo = await fooQuery.first();

Output:

console.log(foo); -> Foo { _objCount: 0, className: 'Foo', id: 'Pm9XMEiEp3' }
console.log(foo.get("propertyOne")); -> undefined

Fetch:
await foo.fetch();

Output:
console.log(foo.get("propertyOne"); -> "This is property one"

You can use include option in your queries.

const fooQuery = new Parse.Query(Foo);
fooQuery.include('pointerField');
const foo = await fooQuery.first();

This way pointer will be available fully and you won’t need to call fetch again

Thanks for the reply.

The funny thing with this is that the property isn’t a pointer, it’s a primitive.

I did figure out what was actually causing the issue though. For some reason or another, if you don’t include an empty constructor that calls through super, things don’t get initialized properly.

The above example was a bit off. I am creating an instance with a constructor with params, and setting the properties inside the constructor like so:

export class Foo extends Parse.Object {
  constructor(params: FooParams) {
    super(“Foo”);
    this.set(“propertyOne”, params.propertyOne);
  }
}

When doing this, I get the results I’m experiencing.

I instead created a static function newInstance that takes in the same parameters and returns an instance and that works perfectly fine.

Not sure if that’s limitation of JavaScript or the framework, but I have a workaround now.

Thanks.

You might need

export class Foo extends Parse.Object {
  constructor(params: FooParams) {
    super("Foo", params);
  }
}