Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/469.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 方法在本地运行良好,部署时不会运行(在meteor.com上)_Javascript_Meteor_Web Deployment - Fatal编程技术网

Javascript 方法在本地运行良好,部署时不会运行(在meteor.com上)

Javascript 方法在本地运行良好,部署时不会运行(在meteor.com上),javascript,meteor,web-deployment,Javascript,Meteor,Web Deployment,我有一个Meteor应用程序可以在本地完美运行,但当我部署到Meteor.com时,有一个方法无法运行。所有其他方法运行良好 以下是相关代码: 客户端:单击按钮将公司添加到阵列中 Template.ValuationTableComps.events ({ 'submit form': function(e) { e.preventDefault(); var valuationId = this._id; var selection =

我有一个Meteor应用程序可以在本地完美运行,但当我部署到Meteor.com时,有一个方法无法运行。所有其他方法运行良好

以下是相关代码:

客户端:单击按钮将公司添加到阵列中

Template.ValuationTableComps.events ({
    'submit form': function(e) {
        e.preventDefault();
        var valuationId = this._id;
        var selection = {
        valuationSelections: $(e.target).find('[name=selectionComp]').val()};
        Valuations.update(valuationId, {$addToSet: selection}, function () {});
    }
});
客户端:按钮单击以根据上述选择重新运行阵列

Template.ValuationCalc.events({
    'click #agg': function(e) {
        e.preventDefault();
        var valuationId = this._id;
        var valuationSelections = this.valuationSelections;
        Meteor.call('valuationAggregate', valuationId, valuationSelections, function (error, result) {});
    }
});
Lib:运行聚合并将结果上传到新集合中的方法

Meteor.methods({
    valuationAggregate: function(valuationId, valuationSelections) {
        if (Meteor.isServer) {
            check(valuationId, String);
            check(valuationSelections, Array);
            var pipelineSelections = [
            //build pipeline//
            ];
            var results = Companies.aggregate(pipelineSelections);
            results.forEach(function(valuationResults) {
                ValuationResults.update({valuationId: valuationId}, valuationResults, {upsert: true});
            });
        }
    }});
在本地计算机上运行时,这一切都可以正常工作。我可以在客户端和服务器上console.log
valuationId
valuationSelections
ValuationResults.find({valuationId:valuationId}).fetch()
,并返回正确的结果

但是,当我部署到meteor.com时,该方法将不会运行。在我的浏览器控制台中,我看到
valuationId
valuationselection
。但是,ValuationResults查询返回
[]

我在ValuationResults中有虚拟数据,我可以在浏览器控制台中看到这些数据,因此集合很好。但是我不明白为什么这个方法可以在本地工作,而不能在部署的服务器上工作。这是唯一不起作用的东西,其他的都没问题。谢谢。

已解决:

我能够运行meteor logs myApp,发现有一个错误
MongoError:exception:无效运算符“$literal”
。我的
$project
阶段包括
valuationId:{$literal:valuationId}
以向新文档添加新字段。我不知道这到底是为什么会抛出错误,但似乎有一个已知的mongodb问题:

我从管道中取出了
$literal
,只是更新了现有的估价文档。现在可以在本地和部署时正常工作。

已解决:

我能够运行meteor logs myApp,发现有一个错误
MongoError:exception:无效运算符“$literal”
。我的
$project
阶段包括
valuationId:{$literal:valuationId}
以向新文档添加新字段。我不知道这到底是为什么会抛出错误,但似乎有一个已知的mongodb问题:


我从管道中取出了
$literal
,只是更新了现有的估价文档。现在在本地和部署时都可以正常工作。

从这里开始:@JeremyK,非常感谢,我可以使用您的建议看到错误,添加了分辨率作为答案。从这里开始:@JeremyK,非常感谢,我可以使用您的建议看到错误,添加了分辨率作为答案。