使用打字稿解析查询
Parse query with typescript
我在解析服务器的云代码中使用打字稿,但在保存和获取对象时遇到了一些问题。
在main.js文件中我注册了下一个class:
Parse.Object.registerSubclass('Subscription', Subscription);
Subscription.ts:
export class Subscription extends Parse.Object {...}
保存对象如:
obj = new Parse.Object(Subscription)
它将创建一个 class "undefined" 存储数据。
但是输入 obj = new Parse.Object("Subscription");
没问题。
有什么想法吗?谢谢!
使用 类 扩展 Parse.Object 时,您需要直接创建这些对象的新实例:
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);
我在解析服务器的云代码中使用打字稿,但在保存和获取对象时遇到了一些问题。
在main.js文件中我注册了下一个class:
Parse.Object.registerSubclass('Subscription', Subscription);
Subscription.ts:
export class Subscription extends Parse.Object {...}
保存对象如:
obj = new Parse.Object(Subscription)
它将创建一个 class "undefined" 存储数据。
但是输入 obj = new Parse.Object("Subscription");
没问题。
有什么想法吗?谢谢!
使用 类 扩展 Parse.Object 时,您需要直接创建这些对象的新实例:
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);