是否可以将类添加到解析云代码中

Is it possible to add classes to Parse Cloud Code?

本文关键字:代码 添加 是否      更新时间:2023-09-26

我想将这些类添加到我的解析云代码中:

   function Rule = {
    this.accessor = new Accessor(); 
    this.act = new Action(); 
}
Rule.prototype.sendEmail = function(email, threshold, bill){
    if (this.accessor.check(threshold, bill)){
        this.act.actionTake(email, threshold, bill); 
    }
}; 
function Accessor = {
}
Accessor.prototype.check = function(threshold, bill){
    return bill > threshold; 
}; 
function Action = {
}
Action.prototype.actionTake = function(email, threshold, bill){
    //send email code 
}; 

但是当我确实将其添加到javascript文件的最顶部时

我得到Update failed with Could not load triggers. The error was Uncaught SyntaxErrorL Unexpected token in main.js:1

解析云代码只是为了定义后台作业和云函数吗?是否可以将"类"定义添加到解析云代码中?

谢谢

var Rule = function() { this.accessor = new Accessor(); this.act = new Action(); };

function Rule() { this.accessor = new Accessor(); this.act = new Action(); }

基本的JS语法,与解析无关