0

Im using typescript in the cloud code of my parse server but Im getting some problems saving and getting objects.

In the main.js file I have registered the next class:

Parse.Object.registerSubclass('Subscription', Subscription);

Subscription.ts:

export class Subscription extends Parse.Object {...}

Saving a object like: obj = new Parse.Object(Subscription) it is going to create a class "undefined" storing there the data.

But typing obj = new Parse.Object("Subscription"); its work ok.

Any idea? Thanks!

4
  • Did you try using new Subscription() and followed the JS guide: docs.parseplatform.org/js/guide/#objects Commented Jun 23, 2018 at 13:42
  • Yes, my fault , with new Subscription works Commented Jun 23, 2018 at 13:45
  • So it’s how it should be Commented Jun 25, 2018 at 13:50
  • Yes, if you want to answer it Im going to mark it as correct Commented Jun 25, 2018 at 14:37

1 Answer 1

1

When using classes extending Parse.Object, you'll need to create new instances of those objects directly:

export class Subscription extends Parse.Object {
  constructor() {
    // Pass the ClassName to the Parse.Object constructor
    super('Subscription');
  }
}

However, when using extends, the SDK is not automatically aware of your subclass. If you want objects returned from queries to use your subclass of Parse.Object, you will need to register the subclass, similar to what we do on other platforms.

// After specifying the Subscription subclass...
Parse.Object.registerSubclass('Subscription', Subscription);

See http://docs.parseplatform.org/js/guide/#objects for more informations

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.