I’m getting a plain ParseObject instead of the registered subclass as a result of queries. This is how I’m defining my class in Typescript:
import * as Parse from 'parse/node';
export interface MyClassAttributes {
id: string;
objectId: string;
createdAt: Date;
updatedAt: Date;
someData: string;
}
export class MyClass extends Parse.Object<MyClassAttributes> {
constructor (data?: Partial<MyClassAttributes>) {
super('MyClass', data as MyClassAttributes);
}
}
Parse.Object.registerSubclass('MyClass', MyClass);
Here’s my cloud function. The cloud function file is imported after the class definition, and the code is something like this:
import { MyType } from '../classes/MyType';
Parse.Cloud.define(
'myFunction',
async (request): Promise<MyDataInterface> => {
const myObjectId = 'xxxxx'; // dynamic
const query = new Parse.Query(MyType);
let myInstance = await query.get(myObjectId, { useMasterKey: true });
console.log(myInstance, myInstance.constructor.name);
});
When called, I get this as output:
ParseObject { _objCount: 21, className: 'MyClass', id: 'gO2Ru31MrP' } ParseObject
Any idea of what I could be doing wrong or how to cast to the proper class? Thank you