Parse Cloud Code中的常量

时间:2015-09-22 12:36:10

标签: parse-platform

如何在Parse的云代码中实现全局常量?我将我的云代码功能分成几个文件以保持可管理性。我有需要在这些文件中使用的常量。在云代码中实现这一点的最佳方法是什么?

1 个答案:

答案 0 :(得分:4)

我明白了。我创建了一个名为constants.js的模块文件

module.exports = {
    initialize: function() {
        return this;
    },
    version: '1.0.0'
}

// Some constant
module.exports.SOME_CONSTANT = 0;

然后在我需要的任何文件中。

var Constants = require('cloud/constants.js');

Constants.SOME_CONSTANT; // 0